mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-02 17:28:48 +00:00
LibURL+LibWeb: Make URL::basic_parse return an Optional<URL>
URL::basic_parse has a subtle bug where the resulting URL is not set to valid when StateOveride is provided and the URL parser early returns a valid URL. This has not surfaced as a problem so far, as the only users of the state override API provide an already valid URL buffer and also ignore the result of basic parsing with a state override. However, this bug surfaces implementing the URL pattern spec, which as part of URL canonicalization: * Provides a dummy URL record * Basic URL parses that URL with state override * Checks the result of the URL parser to validate the URL While we could set URL validity on every early return of the URL parser during state override, it has been a long standing FIXME around the code to try and remove the awkward validity state of the URL class. So this commit makes the first stage of this change by migrating the basic parser API to return Optional, which also happens to make this subtle issue not a problem any more.
This commit is contained in:
parent
b6ec055bf9
commit
5bed8f4055
Notes:
github-actions[bot]
2025-01-11 15:09:28 +00:00
Author: https://github.com/shannonbooth
Commit: 5bed8f4055
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3206
Reviewed-by: https://github.com/trflynn89 ✅
9 changed files with 56 additions and 56 deletions
|
@ -196,7 +196,7 @@ WebIDL::ExceptionOr<void> Location::set_protocol(String const& value)
|
|||
auto possible_failure = URL::Parser::basic_parse(value, {}, ©_url, URL::Parser::State::SchemeStart);
|
||||
|
||||
// 5. If possibleFailure is failure, then throw a "SyntaxError" DOMException.
|
||||
if (!possible_failure.is_valid())
|
||||
if (!possible_failure.has_value())
|
||||
return WebIDL::SyntaxError::create(realm(), MUST(String::formatted("Failed to set protocol. '{}' is an invalid protocol", value)));
|
||||
|
||||
// 6. if copyURL's scheme is not an HTTP(S) scheme, then terminate these steps.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue