Skip to content

Commit 0acff3b

Browse files
committed
Fix interaction of skip_whitespace and nested blocks
This fixes (at least some of) the test failures at servo/servo#18171
1 parent 9542ab4 commit 0acff3b

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cssparser"
3-
version = "0.19.4"
3+
version = "0.19.5"
44
authors = [ "Simon Sapin <simon.sapin@exyr.org>" ]
55

66
description = "Rust implementation of CSS Syntax Level 3"

src/parser.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -291,17 +291,19 @@ impl<'i: 't, 't> Parser<'i, 't> {
291291
/// Advance the input until the next token that’s not whitespace or a comment.
292292
#[inline]
293293
pub fn skip_whitespace(&mut self) {
294-
// If we just consumed `{`, `[`, `(`, or `function(`, leave whitespace
295-
// or comments inside the block or function up to the nested parser.
296-
if self.at_start_of.is_some() {
297-
return
294+
if let Some(block_type) = self.at_start_of.take() {
295+
consume_until_end_of_block(block_type, &mut self.input.tokenizer);
298296
}
299297

300298
self.input.tokenizer.skip_whitespace()
301299
}
302300

303301
#[inline]
304302
pub(crate) fn skip_cdc_and_cdo(&mut self) {
303+
if let Some(block_type) = self.at_start_of.take() {
304+
consume_until_end_of_block(block_type, &mut self.input.tokenizer);
305+
}
306+
305307
self.input.tokenizer.skip_cdc_and_cdo()
306308
}
307309

0 commit comments

Comments
 (0)