csstokenizer: Consume the \ when encountering an error

Otherwise we infinitely end up with the error again.

Testcases added.
This commit is contained in:
Benjamin Otte 2019-05-06 05:56:06 +02:00
parent 15b8ee4564
commit 562e492056
8 changed files with 52 additions and 0 deletions

View File

@ -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;
}

View File

@ -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',

View File

@ -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;
}

View File

@ -0,0 +1 @@
newline-after-backslash-original.css:21:1-2: error: GTK_CSS_PARSER_ERROR_SYNTAX

View File

@ -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);
}

View File

@ -0,0 +1 @@
\

View File

@ -0,0 +1 @@
newline-after-backslash.css:1:1-2: error: GTK_CSS_PARSER_ERROR_SYNTAX