mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 01:51:03 +09:00
Everywhere: Remove some use of the URL constructors
These make it too easy to construct an invalid URL, which makes it difficult to remove the valid state of URL - which this API relies on.
This commit is contained in:
parent
2823ac92d0
commit
d62cf0a807
Notes:
github-actions[bot]
2025-02-19 13:02:46 +00:00
Author: https://github.com/shannonbooth
Commit: d62cf0a807
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3609
Reviewed-by: https://github.com/trflynn89
11 changed files with 341 additions and 329 deletions
|
@ -6,6 +6,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibURL/Parser.h>
|
||||
#include <LibWeb/Bindings/CSSStyleSheetPrototype.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/CSS/CSSImportRule.h>
|
||||
|
@ -42,10 +43,10 @@ WebIDL::ExceptionOr<GC::Ref<CSSStyleSheet>> CSSStyleSheet::construct_impl(JS::Re
|
|||
if (options.has_value() && options->base_url.has_value()) {
|
||||
Optional<URL::URL> sheet_location_url;
|
||||
if (sheet->location().has_value())
|
||||
sheet_location_url = sheet->location().release_value();
|
||||
sheet_location_url = URL::Parser::basic_parse(sheet->location().release_value());
|
||||
|
||||
// AD-HOC: This isn't explicitly mentioned in the specification, but multiple modern browsers do this.
|
||||
Optional<URL::URL> url = sheet->location().has_value() ? sheet_location_url->complete_url(options->base_url.value()) : options->base_url.value();
|
||||
Optional<URL::URL> url = sheet->location().has_value() ? sheet_location_url->complete_url(options->base_url.value()) : URL::Parser::basic_parse(options->base_url.value());
|
||||
if (!url.has_value())
|
||||
return WebIDL::NotAllowedError::create(realm, "Constructed style sheets must have a valid base URL"_string);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue