Honor quoted-pairs in parameter values

split_unquoted ended a quoted-string at an escaped quote, so
name="a\"; filename=evil.php" came apart into a name and a filename that
a parser in front following RFC 9110 would not see. Skip quoted-pairs
when splitting, and unescape \" and \\ in Content-Disposition values,
leaving other backslashes, such as those of a Windows path, as they are.
This commit is contained in:
yhirose committed 2026-10-16 16:39:00 -04:00
1 parent d5851d7e89
commit 64bebd3b2b
2 files changed
+29 -3

No files matched your search

+6
View File
@@ -1857,6 +1857,12 @@ TEST(ParseDispositionParamsTest, QuotedValues) {
// A parameter with no key is dropped rather than turned into one whose
// key is the value
{"=nokey; name=\"file5\"", {{"name", "file5"}}},
// An escaped quote does not end the value
{"name=\"a\\\"; filename=evil.php\"",
{{"name", "a\"; filename=evil.php"}}},
// Other backslashes, as in a Windows path, are kept
{"name=\"f\"; filename=\"C:\\dir\\a.txt\"",
{{"name", "f"}, {"filename", "C:\\dir\\a.txt"}}},
};
for (const auto &c : cases) {