diff --git a/Tests/LibWeb/Text/expected/URL/invalid-urls.txt b/Tests/LibWeb/Text/expected/URL/invalid-urls.txt index 7ffbe3d1b7b..b58cdb108e6 100644 --- a/Tests/LibWeb/Text/expected/URL/invalid-urls.txt +++ b/Tests/LibWeb/Text/expected/URL/invalid-urls.txt @@ -1,2 +1,4 @@ new URL('file://xn--/p', undefined) error creating URL: 'TypeError: Invalid URL' +new URL('http://0xffffffff1', undefined) +error creating URL: 'TypeError: Invalid URL' diff --git a/Tests/LibWeb/Text/input/URL/invalid-urls.html b/Tests/LibWeb/Text/input/URL/invalid-urls.html index b8f73c9fece..bb0e774765f 100644 --- a/Tests/LibWeb/Text/input/URL/invalid-urls.html +++ b/Tests/LibWeb/Text/input/URL/invalid-urls.html @@ -3,6 +3,7 @@ test(() => { const urls = [ { input: 'file://xn--/p' }, + { input: 'http://0xffffffff1' }, ]; for (url of urls) { diff --git a/Userland/Libraries/LibURL/Parser.cpp b/Userland/Libraries/LibURL/Parser.cpp index 6a9aa801b86..f69afda01bd 100644 --- a/Userland/Libraries/LibURL/Parser.cpp +++ b/Userland/Libraries/LibURL/Parser.cpp @@ -583,7 +583,8 @@ static bool ends_in_a_number_checker(StringView input) return true; // 5. If parsing last as an IPv4 number does not return failure, then return true. - if (parse_ipv4_number(last).has_value()) + // NOTE: This is equivalent to checking that last is "0X" or "0x", followed by zero or more ASCII hex digits. + if (last.starts_with("0x"sv, CaseSensitivity::CaseInsensitive) && all_of(last.substring_view(2), is_ascii_hex_digit)) return true; // 6. Return false.