[gtk] csstokenizer: Consume the \ when encountering an error
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk] csstokenizer: Consume the \ when encountering an error
- Date: Mon, 6 May 2019 03:57:12 +0000 (UTC)
commit 562e4920565b0e5e4c859474916ffa3f41f42916
Author: Benjamin Otte <otte redhat com>
Date: Mon May 6 05:56:06 2019 +0200
csstokenizer: Consume the \ when encountering an error
Otherwise we infinitely end up with the error again.
Testcases added.
gtk/css/gtkcsstokenizer.c | 1 +
testsuite/css/parser/meson.build | 6 ++++++
.../parser/newline-after-backslash-original.css | 24 ++++++++++++++++++++++
.../parser/newline-after-backslash-original.errors | 1 +
.../newline-after-backslash-original.ref.css | 18 ++++++++++++++++
testsuite/css/parser/newline-after-backslash.css | 1 +
.../css/parser/newline-after-backslash.errors | 1 +
.../css/parser/newline-after-backslash.ref.css | 0
8 files changed, 52 insertions(+)
---
diff --git a/gtk/css/gtkcsstokenizer.c b/gtk/css/gtkcsstokenizer.c
index b956c86504..90e781c04f 100644
--- a/gtk/css/gtkcsstokenizer.c
+++ b/gtk/css/gtkcsstokenizer.c
@@ -1376,6 +1376,7 @@ gtk_css_tokenizer_read_token (GtkCssTokenizer *tokenizer,
else
{
gtk_css_token_init (token, GTK_CSS_TOKEN_DELIM, '\\');
+ gtk_css_tokenizer_consume_ascii (tokenizer);
gtk_css_tokenizer_parse_error (error, "Newline may not follow '\' escape character");
return FALSE;
}
diff --git a/testsuite/css/parser/meson.build b/testsuite/css/parser/meson.build
index bedebff64e..4ab3fbb305 100644
--- a/testsuite/css/parser/meson.build
+++ b/testsuite/css/parser/meson.build
@@ -347,6 +347,12 @@ test_data = [
'min-height.ref.css',
'min-width.css',
'min-width.ref.css',
+ 'newline-after-backslash.css',
+ 'newline-after-backslash.errors',
+ 'newline-after-backslash.ref.css',
+ 'newline-after-backslash-original.css',
+ 'newline-after-backslash-original.errors',
+ 'newline-after-backslash-original.ref.css',
'no-semicolon.css',
'no-semicolon.errors',
'no-semicolon.ref.css',
diff --git a/testsuite/css/parser/newline-after-backslash-original.css
b/testsuite/css/parser/newline-after-backslash-original.css
new file mode 100644
index 0000000000..1c5d0c1f78
--- /dev/null
+++ b/testsuite/css/parser/newline-after-backslash-original.css
@@ -0,0 +1,24 @@
+/*
+You can type here any CSS rule recognized by GTK.
+You can temporarily disable this custom CSS by clicking on the “Pause” button above.
+
+Changes are applied instantly and globally, for the whole application.
+*/
+
+
+modelbutton.flat:hover {
+ background-color: red;
+}
+
+popover arrow {
+ background-color: lime;
+ border-width: 2px;
+ border-color: green;
+}
+
+popover {
+}
+\
+popover contents {
+ background-color: magenta;
+}
\ No newline at end of file
diff --git a/testsuite/css/parser/newline-after-backslash-original.errors
b/testsuite/css/parser/newline-after-backslash-original.errors
new file mode 100644
index 0000000000..8b4ff422a9
--- /dev/null
+++ b/testsuite/css/parser/newline-after-backslash-original.errors
@@ -0,0 +1 @@
+newline-after-backslash-original.css:21:1-2: error: GTK_CSS_PARSER_ERROR_SYNTAX
diff --git a/testsuite/css/parser/newline-after-backslash-original.ref.css
b/testsuite/css/parser/newline-after-backslash-original.ref.css
new file mode 100644
index 0000000000..1f34fb3203
--- /dev/null
+++ b/testsuite/css/parser/newline-after-backslash-original.ref.css
@@ -0,0 +1,18 @@
+popover {
+}
+
+popover arrow {
+ background-color: rgb(0,255,0);
+ border-bottom-color: rgb(0,128,0);
+ border-bottom-width: 2px;
+ border-left-color: rgb(0,128,0);
+ border-left-width: 2px;
+ border-right-color: rgb(0,128,0);
+ border-right-width: 2px;
+ border-top-color: rgb(0,128,0);
+ border-top-width: 2px;
+}
+
+modelbutton:hover.flat {
+ background-color: rgb(255,0,0);
+}
diff --git a/testsuite/css/parser/newline-after-backslash.css
b/testsuite/css/parser/newline-after-backslash.css
new file mode 100644
index 0000000000..1233d0e5d4
--- /dev/null
+++ b/testsuite/css/parser/newline-after-backslash.css
@@ -0,0 +1 @@
+\
diff --git a/testsuite/css/parser/newline-after-backslash.errors
b/testsuite/css/parser/newline-after-backslash.errors
new file mode 100644
index 0000000000..157d994484
--- /dev/null
+++ b/testsuite/css/parser/newline-after-backslash.errors
@@ -0,0 +1 @@
+newline-after-backslash.css:1:1-2: error: GTK_CSS_PARSER_ERROR_SYNTAX
diff --git a/testsuite/css/parser/newline-after-backslash.ref.css
b/testsuite/css/parser/newline-after-backslash.ref.css
new file mode 100644
index 0000000000..e69de29bb2
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]