Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/common/cache_control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,15 @@ mod tests {
);
}

#[test]
fn test_parse_quoted_comma() {
assert_eq!(
test_decode::<CacheControl>(&["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!(
Expand Down
20 changes: 19 additions & 1 deletion src/util/csv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down