From 8ac096c0e203400a503e792b3638d082eade2de8 Mon Sep 17 00:00:00 2001 From: Shannon Booth Date: Fri, 25 Apr 2025 21:46:49 +1200 Subject: [PATCH] LibWeb/HTML: Fix parsing of protocol in Location.protocol setter This never worked properly when implemented as it would always throw an error for an invalid scheme on URL parsing. Fixes at least some tests in: https://wpt.live/html/browsers/history/the-location-interface/location-protocol-setter-non-broken.html And all tests in: https://wpt.live/html/browsers/history/the-location-interface/location-protocol-setter-non-broken-weird.html And maybe tests in some other places too, but these are not imported as the tests are written with delays that makes them take a long time to run, and some of them rely on HTTP(s). --- Libraries/LibWeb/HTML/Location.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Libraries/LibWeb/HTML/Location.cpp b/Libraries/LibWeb/HTML/Location.cpp index 02f016be28a..b50a9205db3 100644 --- a/Libraries/LibWeb/HTML/Location.cpp +++ b/Libraries/LibWeb/HTML/Location.cpp @@ -195,7 +195,7 @@ WebIDL::ExceptionOr Location::set_protocol(String const& value) auto copy_url = this->url(); // 4. Let possibleFailure be the result of basic URL parsing the given value, followed by ":", with copyURL as url and scheme start state as state override. - auto possible_failure = URL::Parser::basic_parse(value, {}, ©_url, URL::Parser::State::SchemeStart); + auto possible_failure = URL::Parser::basic_parse(MUST(String::formatted("{}:", value)), {}, ©_url, URL::Parser::State::SchemeStart); // 5. If possibleFailure is failure, then throw a "SyntaxError" DOMException. if (!possible_failure.has_value())