diff --git a/Libraries/LibWeb/Fetch/Body.cpp b/Libraries/LibWeb/Fetch/Body.cpp index 9408a5e4386..bd87072911f 100644 --- a/Libraries/LibWeb/Fetch/Body.cpp +++ b/Libraries/LibWeb/Fetch/Body.cpp @@ -394,7 +394,9 @@ MultipartParsingErrorOr> parse_multipart_form_data(JS return MultipartParsingError { MUST(String::formatted("Expected `--` followed by boundary at position {}", lexer.tell())) }; // 2. If position points to the sequence of bytes 0x2D 0x2D 0x0D 0x0A (`--` followed by CR LF) followed by the end of input, return entry list. - if (lexer.next_is("--\r\n"sv)) + // NOTE: We do not require the input to end with CRLF to match the behavior of other browsers. According to RFC 2046, we are to discard any + // text after the terminating `--`. See: https://datatracker.ietf.org/doc/html/rfc2046#page-22 + if (lexer.next_is("--"sv)) return entry_list; // 3. If position does not point to a sequence of bytes starting with 0x0D 0x0A (CR LF), return failure. diff --git a/Tests/LibWeb/Text/expected/Fetch/multipart-form-data-crlf.txt b/Tests/LibWeb/Text/expected/Fetch/multipart-form-data-crlf.txt new file mode 100644 index 00000000000..73cc57085a7 --- /dev/null +++ b/Tests/LibWeb/Text/expected/Fetch/multipart-form-data-crlf.txt @@ -0,0 +1,6 @@ +Data: value0 +Data: value1 +Data: value2 +Data: value3 +Data: value4 +Data: value5 diff --git a/Tests/LibWeb/Text/input/Fetch/multipart-form-data-crlf.html b/Tests/LibWeb/Text/input/Fetch/multipart-form-data-crlf.html new file mode 100644 index 00000000000..157edadf58d --- /dev/null +++ b/Tests/LibWeb/Text/input/Fetch/multipart-form-data-crlf.html @@ -0,0 +1,36 @@ + + +