mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Handle multibyte characters in img srcset (#33873)
This was causing this web platform test to crash: https://wpt.fyi/results/html/semantics/embedded-content/the-img-element/srcset/parse-a-srcset-attribute.html Signed-off-by: evuez <julien@mulga.net>
This commit is contained in:
parent
2d796a2719
commit
72ff89620b
2 changed files with 168 additions and 5 deletions
|
@ -2011,8 +2011,8 @@ pub fn parse_a_srcset_attribute(input: &str) -> Vec<ImageSource> {
|
|||
// > that position is past the end of input.
|
||||
let mut characters = descriptors_string.chars();
|
||||
let mut character = characters.next();
|
||||
if character.is_some() {
|
||||
current_index += 1;
|
||||
if let Some(character) = character {
|
||||
current_index += character.len_utf8();
|
||||
}
|
||||
|
||||
loop {
|
||||
|
@ -2086,8 +2086,8 @@ pub fn parse_a_srcset_attribute(input: &str) -> Vec<ImageSource> {
|
|||
}
|
||||
|
||||
character = characters.next();
|
||||
if character.is_some() {
|
||||
current_index += 1;
|
||||
if let Some(character) = character {
|
||||
current_index += character.len_utf8();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,2 +1,165 @@
|
|||
[parse-a-srcset-attribute.html]
|
||||
expected: CRASH
|
||||
["data:,a,, , "]
|
||||
expected: FAIL
|
||||
|
||||
[",,,data:,a"]
|
||||
expected: FAIL
|
||||
|
||||
[" , ,,data:,a"]
|
||||
expected: FAIL
|
||||
|
||||
["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 1 w" (trailing U+1680)]
|
||||
expected: FAIL
|
||||
|
||||
["data:,a 1 w" (trailing U+2000)]
|
||||
expected: FAIL
|
||||
|
||||
["data:,a 1 w" (trailing U+2001)]
|
||||
expected: FAIL
|
||||
|
||||
["data:,a 1 w" (trailing U+2002)]
|
||||
expected: FAIL
|
||||
|
||||
["data:,a 1 w" (trailing U+2003)]
|
||||
expected: FAIL
|
||||
|
||||
["data:,a 1 w" (trailing U+2004)]
|
||||
expected: FAIL
|
||||
|
||||
["data:,a 1 w" (trailing U+2005)]
|
||||
expected: FAIL
|
||||
|
||||
["data:,a 1 w" (trailing U+2006)]
|
||||
expected: FAIL
|
||||
|
||||
["data:,a 1 w" (trailing U+2007)]
|
||||
expected: FAIL
|
||||
|
||||
["data:,a 1 w" (trailing U+2008)]
|
||||
expected: FAIL
|
||||
|
||||
["data:,a 1 w" (trailing U+2009)]
|
||||
expected: FAIL
|
||||
|
||||
["data:,a 1 w" (trailing U+200A)]
|
||||
expected: FAIL
|
||||
|
||||
["data:,a 1w" (trailing U+200C)]
|
||||
expected: FAIL
|
||||
|
||||
["data:,a 1w" (trailing U+200D)]
|
||||
expected: FAIL
|
||||
|
||||
["data:,a 1 w" (trailing U+202F)]
|
||||
expected: FAIL
|
||||
|
||||
["data:,a 1 w" (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 1 h" (trailing U+1680)]
|
||||
expected: FAIL
|
||||
|
||||
["data:,a 1w 1 h" (trailing U+2000)]
|
||||
expected: FAIL
|
||||
|
||||
["data:,a 1w 1 h" (trailing U+2001)]
|
||||
expected: FAIL
|
||||
|
||||
["data:,a 1w 1 h" (trailing U+2002)]
|
||||
expected: FAIL
|
||||
|
||||
["data:,a 1w 1 h" (trailing U+2003)]
|
||||
expected: FAIL
|
||||
|
||||
["data:,a 1w 1 h" (trailing U+2004)]
|
||||
expected: FAIL
|
||||
|
||||
["data:,a 1w 1 h" (trailing U+2005)]
|
||||
expected: FAIL
|
||||
|
||||
["data:,a 1w 1 h" (trailing U+2006)]
|
||||
expected: FAIL
|
||||
|
||||
["data:,a 1w 1 h" (trailing U+2007)]
|
||||
expected: FAIL
|
||||
|
||||
["data:,a 1w 1 h" (trailing U+2008)]
|
||||
expected: FAIL
|
||||
|
||||
["data:,a 1w 1 h" (trailing U+2009)]
|
||||
expected: FAIL
|
||||
|
||||
["data:,a 1w 1 h" (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 1 h" (trailing U+202F)]
|
||||
expected: FAIL
|
||||
|
||||
["data:,a 1w 1 h" (trailing U+205F)]
|
||||
expected: FAIL
|
||||
|
||||
["data:,a 1w 1 h" (trailing U+3000)]
|
||||
expected: FAIL
|
||||
|
||||
["data:,a 1w 1h" (trailing U+FEFF)]
|
||||
expected: FAIL
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue