LibWeb: In MimeType serialization, put just one \ in front of each "

This commit is contained in:
Nico Weber 2022-09-27 10:44:18 -04:00 committed by Linus Groh
commit bf6d5fce18
Notes: sideshowbarker 2024-07-17 06:35:13 +09:00

View file

@ -196,8 +196,8 @@ String MimeType::serialized() const
// 4. If value does not solely contain HTTP token code points or value is the empty string, then: // 4. If value does not solely contain HTTP token code points or value is the empty string, then:
if (!contains_only_http_token_code_points(value) || value.is_empty()) { if (!contains_only_http_token_code_points(value) || value.is_empty()) {
// 1. Precede each occurence of U+0022 (") or U+005C (\) in value with U+005C (\). // 1. Precede each occurence of U+0022 (") or U+005C (\) in value with U+005C (\).
value = value.replace("\""sv, "\\\""sv, ReplaceMode::All);
value = value.replace("\\"sv, "\\\\"sv, ReplaceMode::All); value = value.replace("\\"sv, "\\\\"sv, ReplaceMode::All);
value = value.replace("\""sv, "\\\""sv, ReplaceMode::All);
// 2. Prepend U+0022 (") to value. // 2. Prepend U+0022 (") to value.
// 3. Append U+0022 (") to value. // 3. Append U+0022 (") to value.