From 4b6f0ee24a813f5d0703789c5dee9b7198ee0eb0 Mon Sep 17 00:00:00 2001 From: Shannon Booth Date: Mon, 7 Apr 2025 11:27:32 +1200 Subject: [PATCH] LibURL: Do not trim whitespace parsing port in URL parser This has no functional difference as far as I can tell, but for clarity explicitly do not attempt to do this, which has the nice side effect of not checking for whitespace known to not exist. --- Libraries/LibURL/Parser.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Libraries/LibURL/Parser.cpp b/Libraries/LibURL/Parser.cpp index c72249cad33..14418a7f892 100644 --- a/Libraries/LibURL/Parser.cpp +++ b/Libraries/LibURL/Parser.cpp @@ -140,11 +140,11 @@ static Optional parse_ipv4_number(StringView input) // 8. Let output be the mathematical integer value that is represented by input in radix-R notation, using ASCII hex digits for digits with values 0 through 15. Optional maybe_output; if (radix == 8) - maybe_output = AK::StringUtils::convert_to_uint_from_octal(input); + maybe_output = AK::StringUtils::convert_to_uint_from_octal(input, TrimWhitespace::No); else if (radix == 10) - maybe_output = input.to_number(); + maybe_output = input.to_number(TrimWhitespace::No); else if (radix == 16) - maybe_output = AK::StringUtils::convert_to_uint_from_hex(input); + maybe_output = AK::StringUtils::convert_to_uint_from_hex(input, TrimWhitespace::No); else VERIFY_NOT_REACHED(); @@ -1250,7 +1250,7 @@ Optional Parser::basic_parse(StringView raw_input, Optional bas // 1. If buffer is not the empty string: if (!buffer.is_empty()) { // 1. Let port be the mathematical integer value that is represented by buffer in radix-10 using ASCII digits for digits with values 0 through 9. - auto port = buffer.string_view().to_number(); + auto port = buffer.string_view().to_number(TrimWhitespace::No); // 2. If port is greater than 2^16 − 1, port-out-of-range validation error, return failure. // NOTE: This is done by to_number.