From 305cac756ae2d30da8ecd090fa30273901059ca4 Mon Sep 17 00:00:00 2001 From: Guillaume Ayoub Date: Sun, 21 Jan 2024 10:43:08 +0100 Subject: [PATCH] Stop pre-parsing declarations on {} blocks only when nested allowed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When nesting is not allowed, we should consume tokens until we meet a semicolon. When it’s allowed, we have to stop at {} blocks to keep possibly valid declarations after them. --- tinycss2/parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tinycss2/parser.py b/tinycss2/parser.py index adfa7d0..ab0a9d4 100644 --- a/tinycss2/parser.py +++ b/tinycss2/parser.py @@ -143,7 +143,7 @@ def _consume_declaration_in_list(first_token, tokens, allow_nested): semicolon_token.append(token) break declaration_tokens.append(token) - if token.type == '{} block': + if allow_nested and token.type == '{} block': break declaration = _parse_declaration(first_token, iter(declaration_tokens)) if not allow_nested or declaration.type == 'declaration':