test quoted string with a foldable whitespace
This commit is contained in:
parent
7052443bb5
commit
6b227d9830
1 changed files with 2 additions and 0 deletions
|
@ -58,6 +58,7 @@ pub fn quoted_string(input: &str) -> IResult<&str, String> {
|
||||||
let (input, _) = tag("\"")(input)?;
|
let (input, _) = tag("\"")(input)?;
|
||||||
let (input, content) = many0(pair(opt(fws), qcontent))(input)?;
|
let (input, content) = many0(pair(opt(fws), qcontent))(input)?;
|
||||||
|
|
||||||
|
// Rebuild string
|
||||||
let mut qstring = content.iter().fold(
|
let mut qstring = content.iter().fold(
|
||||||
String::with_capacity(16),
|
String::with_capacity(16),
|
||||||
|mut acc, (maybe_wsp, c)| {
|
|mut acc, (maybe_wsp, c)| {
|
||||||
|
@ -269,5 +270,6 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_quoted_string() {
|
fn test_quoted_string() {
|
||||||
assert_eq!(quoted_string(" \"hello\\\"world\" "), Ok(("", "hello\"world".to_string())));
|
assert_eq!(quoted_string(" \"hello\\\"world\" "), Ok(("", "hello\"world".to_string())));
|
||||||
|
assert_eq!(quoted_string("\"hello\r\n world\""), Ok(("", "hello world".to_string())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue