Correct line folding in from ics/from vcf (#10577)

# Description
Potential fix for #10398

datatracker.ietf.org/doc/html/rfc5545#section-3.1
datatracker.ietf.org/doc/html/rfc6350#section-3.2

---------

Co-authored-by: Joerg <joerg@schuetter.org>
This commit is contained in:
joergsch
2023-10-03 19:11:16 +02:00
committed by GitHub
parent f481879ed3
commit e8da57b05e
4 changed files with 107 additions and 8 deletions

View File

@ -14,9 +14,17 @@ pub fn from_ics_call(call: &EvaluatedCall, input: &Value) -> Result<Value, Label
let input_string = input_string
.lines()
.map(|x| x.trim().to_string())
.collect::<Vec<_>>()
.join("\n");
.enumerate()
.map(|(i, x)| {
if i == 0 {
x.trim().to_string()
} else if x.len() > 1 && (x.starts_with(' ') || x.starts_with('\t')) {
x[1..].trim_end().to_string()
} else {
format!("\n{}", x.trim())
}
})
.collect::<String>();
let input_bytes = input_string.as_bytes();
let buf_reader = BufReader::new(input_bytes);

View File

@ -13,9 +13,17 @@ pub fn from_vcf_call(call: &EvaluatedCall, input: &Value) -> Result<Value, Label
let input_string = input_string
.lines()
.map(|x| x.trim().to_string())
.collect::<Vec<_>>()
.join("\n");
.enumerate()
.map(|(i, x)| {
if i == 0 {
x.trim().to_string()
} else if x.len() > 1 && (x.starts_with(' ') || x.starts_with('\t')) {
x[1..].trim_end().to_string()
} else {
format!("\n{}", x.trim())
}
})
.collect::<String>();
let input_bytes = input_string.as_bytes();
let cursor = std::io::Cursor::new(input_bytes);