From 400ef9913e340affb45ad134e049fa313ade0b00 Mon Sep 17 00:00:00 2001 From: Ankur Sundara <1sankur1@gmail.com> Date: Sat, 9 Jul 2022 03:13:37 -0700 Subject: [PATCH] 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. --- Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp index 6e2b9ab97d..3768ff8e89 100644 --- a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp +++ b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp @@ -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 regex { R"~~~(^[A-Za-z0-9!#$%&'*+-.^_`|~]+$)~~~" }; + Regex 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 regex { R"~~~(^[A-Za-z0-9!#$%&'*+-.^_`|~]+$)~~~" }; + Regex regex { R"~~~(^[A-Za-z0-9!#$%&'*+\-.^_`|~]+$)~~~" }; return regex.has_match(header_name); }