From: Benjamin Otte Date: Mon, 6 May 2019 03:56:06 +0000 (+0200) Subject: csstokenizer: Consume the \ when encountering an error X-Git-Tag: archive/raspbian/4.4.1+ds1-2+rpi1^2~18^2~21^2~14 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=562e4920565b0e5e4c859474916ffa3f41f42916;p=gtk4.git csstokenizer: Consume the \ when encountering an error Otherwise we infinitely end up with the error again. Testcases added. --- 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