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:
evuez 2024-10-17 04:13:18 -04:00 committed by GitHub
parent 2d796a2719
commit 72ff89620b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 168 additions and 5 deletions

View file

@ -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();
}
}