diff --git a/src/common/cache_control.rs b/src/common/cache_control.rs index 37bfa323..53fbb3ce 100644 --- a/src/common/cache_control.rs +++ b/src/common/cache_control.rs @@ -485,6 +485,15 @@ mod tests { ); } + #[test] + fn test_parse_quoted_comma() { + assert_eq!( + test_decode::(&["foo=\"a, private, immutable, b\", no-cache"]).unwrap(), + CacheControl::new().with_no_cache(), + "unknown extensions are ignored but shouldn't fail parsing", + ) + } + #[test] fn test_parse_extension() { assert_eq!( diff --git a/src/util/csv.rs b/src/util/csv.rs index ff91732e..a3d05ba4 100644 --- a/src/util/csv.rs +++ b/src/util/csv.rs @@ -14,8 +14,26 @@ where values .flat_map(|value| { value.to_str().into_iter().flat_map(|string| { + let mut in_quotes = false; string - .split(',') + .split(move |c| { + #[allow(clippy::collapsible_else_if)] + if in_quotes { + if c == '"' { + in_quotes = false; + } + false // dont split + } else { + if c == ',' { + true // split + } else { + if c == '"' { + in_quotes = true; + } + false // dont split + } + } + }) .filter_map(|x| match x.trim() { "" => None, y => Some(y),