mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2026-10-19 11:19:36 +00:00
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:
1 parent
d5851d7e89
commit
64bebd3b2b
2 files changed
+29
-3
No files matched your search
@@ -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) {
|
||||
|
||||
Reference in new issue
Block a user