Fix multipart boundary with charset (#1511)

For example
Content-Type: multipart/form-data; boundary=TqmguJb_Fm_eFtAFCpWvmk5iPqrIEJJjvBFn; charset=ISO-8859-1
This commit is contained in:
jinsongzhao 2023-02-18 19:35:58 +08:00 committed by GitHub
parent 54d96963f3
commit 29955becc1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -71,9 +71,10 @@ int MultiPartParser::parse(const HttpRequestPtr &req)
pos = contentType.find("boundary=");
if (pos == std::string::npos)
return -1;
return parse(req,
contentType.data() + (pos + 9),
contentType.size() - (pos + 9));
auto pos2 = contentType.find(';', pos);
if (pos2 == std::string::npos)
pos2 = contentType.size();
return parse(req, contentType.data() + (pos + 9), pos2 - (pos + 9));
}
static std::pair<string_view, string_view> parseLine(const char *begin,
const char *end)