mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-07 21:59:54 +00:00
LibWeb: Do not fetch empty CSS URLs
If a CSS rule has a URL like `url("")`, it would resolve to the document
URL itself. There isn't a context in which this would result in a valid
resource, so the spec tells us to drop it.
No test here because there isn't really a way to know when a CSS URL is
fetched. We could use PerformanceResourceTiming, but that is only for
HTTP(S) URLs. There is already an existing test for serialization of
empty URLs, which still passes.
This commit is contained in:
parent
d8ec204be8
commit
0cb9f4b66f
Notes:
github-actions[bot]
2025-11-12 17:31:53 +00:00
Author: https://github.com/trflynn89
Commit: 0cb9f4b66f
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6801
Reviewed-by: https://github.com/gmta ✅
1 changed files with 6 additions and 0 deletions
|
|
@ -40,6 +40,12 @@ static GC::Ptr<Fetch::Infrastructure::Request> fetch_a_style_resource_impl(Style
|
|||
[](::URL::URL const& url) { return url.to_string(); },
|
||||
[](CSS::URL const& url) { return url.url(); });
|
||||
|
||||
// https://drafts.csswg.org/css-values-4/#url-empty
|
||||
// If the value of the <url> is the empty string (like url("") or url()), the url must resolve to an invalid
|
||||
// resource (similar to what the url about:invalid does).
|
||||
if (url_string.is_empty())
|
||||
return {};
|
||||
|
||||
auto parsed_url = DOMURL::parse(url_string, base);
|
||||
if (!parsed_url.has_value())
|
||||
return {};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue