LibWeb: Treat a CSS declaration with a "--" property name as invalid

This commit is contained in:
Tim Ledbetter 2025-06-25 11:55:17 +01:00 committed by Sam Atkins
commit 7a6e4f5ec8
Notes: github-actions[bot] 2025-06-25 16:10:39 +00:00
3 changed files with 31 additions and 0 deletions

View file

@ -1125,6 +1125,8 @@ Optional<Declaration> Parser::consume_a_declaration(TokenStream<T>& input, Neste
// 8. If decls name is a custom property name string, then set decls original text to the segment
// of the original source text string corresponding to the tokens of decls value.
if (is_invalid_custom_property_name_string(declaration.name))
return {};
if (is_a_custom_property_name_string(declaration.name)) {
// TODO: If we could reach inside the source string that the TokenStream uses, we could grab this as
// a single substring instead of having to reconstruct it.

View file

@ -0,0 +1,13 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<!DOCTYPE html>
<title>CSS Reftest Reference</title>
<link rel="author" title="Cameron McCormack" href="mailto:cam@mcc.id.au">
<style>
p {
color: green;
}
</style>
<p>This text must be green.</p>

View file

@ -0,0 +1,16 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<!DOCTYPE html>
<title>CSS Test: Test a property declaration in an @supports rule with property name "--".</title>
<link rel="author" title="Cameron McCormack" href="mailto:cam@mcc.id.au">
<link rel="help" href="http://www.w3.org/TR/css-variables-1/#defining-variables">
<link rel="match" href="../../../../expected/wpt-import/css/css-variables/support/color-green-ref.html">
<style>
body { color: green; }
@supports (--: a) {
p { color: red; }
}
</style>
<p>This text must be green.</p>