html: Validate descriptors tokens on 'srcset' attribute parsing (#39317)

Follow the specification and validate tokens of the "x/w/h" descriptors
before applying the rules for parsing float-pointing numbers or
non-negative integers.
https://html.spec.whatwg.org/multipage/#parsing-a-srcset-attribute (step
13)

Testing: Improvements in the following tests
-
html/semantics/embedded-content/the-img-element/srcset/parse-a-srcset-attribute.html

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
This commit is contained in:
Andrei Volykhin 2025-09-15 20:34:56 +03:00 committed by GitHub
parent b685c2f424
commit 8c3acaaec9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 36 additions and 167 deletions

View file

@ -1,156 +0,0 @@
[parse-a-srcset-attribute.html]
["data:,a 1.0w"]
expected: FAIL
["data:,a 1e0w"]
expected: FAIL
["data:,a 1www"]
expected: FAIL
["data:,a +1w"]
expected: FAIL
["data:,a 1\\x01w" (trailing U+0001)]
expected: FAIL
["data:,a 1 w" (trailing U+00A0)]
expected: FAIL
["data:,a 1w" (trailing U+1680)]
expected: FAIL
["data:,a 1 w" (trailing U+2000)]
expected: FAIL
["data:,a 1w" (trailing U+2001)]
expected: FAIL
["data:,a 1w" (trailing U+2002)]
expected: FAIL
["data:,a 1w" (trailing U+2003)]
expected: FAIL
["data:,a 1w" (trailing U+2004)]
expected: FAIL
["data:,a 1w" (trailing U+2005)]
expected: FAIL
["data:,a 1w" (trailing U+2006)]
expected: FAIL
["data:,a 1w" (trailing U+2007)]
expected: FAIL
["data:,a 1w" (trailing U+2008)]
expected: FAIL
["data:,a 1w" (trailing U+2009)]
expected: FAIL
["data:,a 1w" (trailing U+200A)]
expected: FAIL
["data:,a 1w" (trailing U+200C)]
expected: FAIL
["data:,a 1w" (trailing U+200D)]
expected: FAIL
["data:,a 1w" (trailing U+202F)]
expected: FAIL
["data:,a 1w" (trailing U+205F)]
expected: FAIL
["data:,a 1 w" (trailing U+3000)]
expected: FAIL
["data:,a 1w" (trailing U+FEFF)]
expected: FAIL
["data:,a 0x"]
expected: FAIL
["data:,a -0x"]
expected: FAIL
["data:,a 1.x"]
expected: FAIL
["data:,a +1x"]
expected: FAIL
["data:,a 1w 1.0h"]
expected: FAIL
["data:,a 1w 1e0h"]
expected: FAIL
["data:,a 1w 1hhh"]
expected: FAIL
["data:,a 1w +1h"]
expected: FAIL
["data:,a 1w 1\\x01h" (trailing U+0001)]
expected: FAIL
["data:,a 1w 1 h" (trailing U+00A0)]
expected: FAIL
["data:,a 1w 1h" (trailing U+1680)]
expected: FAIL
["data:,a 1w 1 h" (trailing U+2000)]
expected: FAIL
["data:,a 1w 1h" (trailing U+2001)]
expected: FAIL
["data:,a 1w 1h" (trailing U+2002)]
expected: FAIL
["data:,a 1w 1h" (trailing U+2003)]
expected: FAIL
["data:,a 1w 1h" (trailing U+2004)]
expected: FAIL
["data:,a 1w 1h" (trailing U+2005)]
expected: FAIL
["data:,a 1w 1h" (trailing U+2006)]
expected: FAIL
["data:,a 1w 1h" (trailing U+2007)]
expected: FAIL
["data:,a 1w 1h" (trailing U+2008)]
expected: FAIL
["data:,a 1w 1h" (trailing U+2009)]
expected: FAIL
["data:,a 1w 1h" (trailing U+200A)]
expected: FAIL
["data:,a 1w 1h" (trailing U+200C)]
expected: FAIL
["data:,a 1w 1h" (trailing U+200D)]
expected: FAIL
["data:,a 1w 1h" (trailing U+202F)]
expected: FAIL
["data:,a 1w 1h" (trailing U+205F)]
expected: FAIL
["data:,a 1w 1 h" (trailing U+3000)]
expected: FAIL
["data:,a 1w 1h" (trailing U+FEFF)]
expected: FAIL