css: Handle invalid :not() selectors

We weren't correctly ending the ( ) block when encountering an error.

Testcases added.

Fixes #2281
This commit is contained in:
Benjamin Otte 2019-12-02 17:31:15 +01:00
parent 564e8f483c
commit 292371932b
5 changed files with 11 additions and 0 deletions

View File

@ -1396,6 +1396,7 @@ gtk_css_selector_parse_selector_pseudo_class (GtkCssParser *parser,
else
{
gtk_css_parser_error_syntax (parser, "Invalid contents of :not() selector");
gtk_css_parser_end_block (parser);
if (selector)
_gtk_css_selector_free (selector);
selector = NULL;
@ -1406,6 +1407,7 @@ gtk_css_selector_parse_selector_pseudo_class (GtkCssParser *parser,
if (!gtk_css_token_is (token, GTK_CSS_TOKEN_EOF))
{
gtk_css_parser_error_syntax (parser, "Invalid contents of :not() selector");
gtk_css_parser_end_block (parser);
if (selector)
_gtk_css_selector_free (selector);
selector = NULL;

View File

@ -369,6 +369,9 @@ test_data = [
'no-semicolon.ref.css',
'not.css',
'not.ref.css',
'not-unclosed.css',
'not-unclosed.errors',
'not-unclosed.ref.css',
'nth-child.css',
'nth-child.ref.css',
'opacity.css',

View File

@ -0,0 +1,3 @@
:not(valid invalid) {}
:not(

View File

@ -0,0 +1,3 @@
not-unclosed.css:1:12-19: error: GTK_CSS_PARSER_ERROR_SYNTAX
not-unclosed.css:4:1: error: GTK_CSS_PARSER_ERROR_SYNTAX
not-unclosed.css:3:2-4:1: error: GTK_CSS_PARSER_WARNING_SYNTAX