Skip to content

Commit

Permalink
Improve multipart filename handling a bit.
Browse files Browse the repository at this point in the history
  • Loading branch information
Relintai committed Mar 10, 2024
1 parent 75e8f68 commit aaf744a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions modules/http_server_simple/http_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,15 @@ void HTTPParser::_process_multipart_header_value(const String &val) {
_multipart_form_name.remove(_multipart_form_name.length() - 1);
}
} else if (kk == "filename") {
_multipart_form_filename = vs.get_slicec('=', 1);
_multipart_form_filename = _multipart_form_filename.replace("\"", "");
_multipart_form_is_file = true;

_multipart_form_filename = vs.get_slicec('=', 1);

if (_multipart_form_filename.length() >= 2 && _multipart_form_filename.begins_with("\"") && _multipart_form_filename.ends_with("\"")) {
_multipart_form_filename.remove(0);
_multipart_form_filename.remove(_multipart_form_filename.length() - 1);
}

if (_multipart_form_name.length() >= 2 && _multipart_form_name.begins_with("\"") && _multipart_form_name.ends_with("\"")) {
_multipart_form_name.remove(0);
_multipart_form_name.remove(_multipart_form_name.length() - 1);
Expand Down Expand Up @@ -635,7 +640,7 @@ int HTTPParser::on_multipart_header_field_cb(const char *at, size_t length) {
}
int HTTPParser::on_multipart_header_value_cb(const char *at, size_t length) {
String s = String::utf8(at, length);

_process_multipart_header_value(s);

#if MULTIPART_MESSAGE_DEBUG
Expand Down

0 comments on commit aaf744a

Please sign in to comment.