[gtk/wip/otte/listview: 1/151] css: Handle invalid :not() selectors
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/listview: 1/151] css: Handle invalid :not() selectors
- Date: Mon, 2 Dec 2019 21:07:47 +0000 (UTC)
commit 6074b9b887ad91e219564ffe0ac854a7522849d7
Author: Benjamin Otte <otte redhat com>
Date: Mon Dec 2 17:31:15 2019 +0100
css: Handle invalid :not() selectors
We weren't correctly ending the ( ) block when encountering an error.
Testcases added.
Fixes #2281
gtk/gtkcssselector.c | 2 ++
testsuite/css/parser/meson.build | 3 +++
testsuite/css/parser/not-unclosed.css | 3 +++
testsuite/css/parser/not-unclosed.errors | 3 +++
testsuite/css/parser/not-unclosed.ref.css | 0
5 files changed, 11 insertions(+)
---
diff --git a/gtk/gtkcssselector.c b/gtk/gtkcssselector.c
index 89ec18194f..b6468bd282 100644
--- a/gtk/gtkcssselector.c
+++ b/gtk/gtkcssselector.c
@@ -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;
diff --git a/testsuite/css/parser/meson.build b/testsuite/css/parser/meson.build
index 1e171aaa36..607faab0bb 100644
--- a/testsuite/css/parser/meson.build
+++ b/testsuite/css/parser/meson.build
@@ -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',
diff --git a/testsuite/css/parser/not-unclosed.css b/testsuite/css/parser/not-unclosed.css
new file mode 100644
index 0000000000..06a801146c
--- /dev/null
+++ b/testsuite/css/parser/not-unclosed.css
@@ -0,0 +1,3 @@
+:not(valid invalid) {}
+
+:not(
diff --git a/testsuite/css/parser/not-unclosed.errors b/testsuite/css/parser/not-unclosed.errors
new file mode 100644
index 0000000000..f83d9d7a2b
--- /dev/null
+++ b/testsuite/css/parser/not-unclosed.errors
@@ -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
diff --git a/testsuite/css/parser/not-unclosed.ref.css b/testsuite/css/parser/not-unclosed.ref.css
new file mode 100644
index 0000000000..e69de29bb2
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]