1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:17:44 +00:00

LibWeb: Fix regexes for XHR

Regexes for is_method and is_header_name did not escape the "-"
and unintentionally allowed for "," to be part of a
method/header name, not following the spec.
This commit escapes the "-" character to follow the spec.
This commit is contained in:
Ankur Sundara 2022-07-09 03:13:37 -07:00 committed by Andreas Kling
parent 75a1442aac
commit 400ef9913e

View file

@ -391,14 +391,14 @@ static bool is_forbidden_method(String const& method)
// https://fetch.spec.whatwg.org/#concept-method
static bool is_method(String const& method)
{
Regex<ECMA262Parser> regex { R"~~~(^[A-Za-z0-9!#$%&'*+-.^_`|~]+$)~~~" };
Regex<ECMA262Parser> regex { R"~~~(^[A-Za-z0-9!#$%&'*+\-.^_`|~]+$)~~~" };
return regex.has_match(method);
}
// https://fetch.spec.whatwg.org/#header-name
static bool is_header_name(String const& header_name)
{
Regex<ECMA262Parser> regex { R"~~~(^[A-Za-z0-9!#$%&'*+-.^_`|~]+$)~~~" };
Regex<ECMA262Parser> regex { R"~~~(^[A-Za-z0-9!#$%&'*+\-.^_`|~]+$)~~~" };
return regex.has_match(header_name);
}