mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-03 14:50:18 +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
|
@ -24,14 +24,14 @@ void fetch_a_style_resource(String const& url_value, CSSStyleSheet const& sheet,
|
|||
|
||||
// 3. Let parsedUrl be the result of the URL parser steps with urlValue’s url and base. If the algorithm returns an error, return.
|
||||
auto parsed_url = URL::Parser::basic_parse(url_value, base);
|
||||
if (!parsed_url.is_valid())
|
||||
if (!parsed_url.has_value())
|
||||
return;
|
||||
|
||||
// 4. Let req be a new request whose url is parsedUrl, whose destination is destination, mode is corsMode,
|
||||
// origin is environmentSettings’s origin, credentials mode is "same-origin", use-url-credentials flag is set,
|
||||
// client is environmentSettings, and whose referrer is environmentSettings’s API base URL.
|
||||
auto request = Fetch::Infrastructure::Request::create(vm);
|
||||
request->set_url(parsed_url);
|
||||
request->set_url(parsed_url.release_value());
|
||||
request->set_destination(destination);
|
||||
request->set_mode(cors_mode == CorsMode::Cors ? Fetch::Infrastructure::Request::Mode::CORS : Fetch::Infrastructure::Request::Mode::NoCORS);
|
||||
request->set_origin(environment_settings.origin());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue