From b2e9861ce4cde3d6b84c7c9866ea5881f66d2661 Mon Sep 17 00:00:00 2001 From: Guillaume Ayoub Date: Sun, 21 Jan 2024 10:31:17 +0100 Subject: [PATCH] Stop pre-parsing declarations after {} blocks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We don’t want to consume tokens after curly brackets as they may be a declaration we want to keep in the tokens iterator. --- tinycss2/parser.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tinycss2/parser.py b/tinycss2/parser.py index 78f4c27..adfa7d0 100644 --- a/tinycss2/parser.py +++ b/tinycss2/parser.py @@ -143,6 +143,8 @@ def _consume_declaration_in_list(first_token, tokens, allow_nested): semicolon_token.append(token) break declaration_tokens.append(token) + if token.type == '{} block': + break declaration = _parse_declaration(first_token, iter(declaration_tokens)) if not allow_nested or declaration.type == 'declaration': return declaration