Match Content-Disposition parameter names case-insensitively (#2698)

parse_disposition_params stored parameter names as they arrived, while FormDataParser looks up "name", "filename" and "filename*" in lower case. A part with NAME= was rejected with 400, and one with FILENAME*= was silently treated as a plain field. Parameter names are case-insensitive (RFC 2045 section 5.1), so the names are now lowercased when stored, as extract_media_type already does for Content-Type. Values keep their case.
This commit is contained in:
Eminy authored and GitHub committed 2026-11-26 19:02:31 -05:00
1 parent bb00fece7c
commit d5befb4326
2 files changed
+6 -1

No files matched your search

+3 -1
View File
@@ -10180,8 +10180,10 @@ inline void parse_disposition_params(const std::string &s, Params &params) {
std::string val;
divide_param_pair(b, e, key, val);
// Parameter names are case-insensitive (RFC 2045 §5.1)
if (!key.empty()) {
params.emplace(trim_double_quotes_copy(key), unquote_param(val));
params.emplace(case_ignore::to_lower(trim_double_quotes_copy(key)),
unquote_param(val));
}
});
}
+3
View File
@@ -2093,6 +2093,9 @@ TEST(ParseDispositionParamsTest, QuotedValues) {
} cases[] = {
{"name=\"file1\"; filename=\"a.txt\"",
{{"name", "file1"}, {"filename", "a.txt"}}},
// MIME parameter names are case-insensitive, but their values are not.
{"NaMe=\"Upload\"; FiLeNaMe=\"Report.TXT\"",
{{"name", "Upload"}, {"filename", "Report.TXT"}}},
// Whitespace around '=' and ';' is still trimmed
{"name=\"file2\" ;filename = \"a.html\"",
{{"name", "file2"}, {"filename", "a.html"}}},