Truly independent web browser
LibWeb: Move a declaration’s empty text along with the rest of its text
sideshowbarker50b137af2753
diff --git a/Libraries/LibWeb/Rust/src/css/parser/syntax_parser.rs b/Libraries/LibWeb/Rust/src/css/parser/syntax_parser.rsindex 4ad01a50ed4..e912f2a00a8 100644--- a/Libraries/LibWeb/Rust/src/css/parser/syntax_parser.rs+++ b/Libraries/LibWeb/Rust/src/css/parser/syntax_parser.rs@@ -3172,16 +3172,15 @@ impl<'a> SyntaxParseBuilder<'a> {for (index, mut declaration) in self.declarations.into_iter().enumerate() {if new_indices[index] != usize::MAX {new_indices[index] = declarations.len();- // NB: A kept declaration's text moves beside the rest of the text the parse keeps.+ // NB: A kept declaration's text moves beside the rest of the text the parse keeps, and empty text too —+ // or its offset would still point into the text it came from, which can run past the end of this.for (offset, length) in [(&mut declaration.name_offset, declaration.name_length),(&mut declaration.value_source_offset, declaration.value_source_length),] {- if length != 0 {- let start = values.len();- values.extend_from_slice(&self.declaration_text[*offset..*offset + length]);- *offset = start;- }+ let start = values.len();+ values.extend_from_slice(&self.declaration_text[*offset..*offset + length]);+ *offset = start;}declarations.push(declaration);}diff --git a/Tests/LibWeb/Crash/CSS/invalid-empty-declarations-in-nested-rule.html b/Tests/LibWeb/Crash/CSS/invalid-empty-declarations-in-nested-rule.htmlnew file mode 100644index 00000000000..b5cfef42eae--- /dev/null+++ b/Tests/LibWeb/Crash/CSS/invalid-empty-declarations-in-nested-rule.html@@ -0,0 +1,9 @@+<!DOCTYPE html>+<style>+ div {+ color: ;+ @media (min-width: 1px) {+ color: ;+ }+ }+</style>