[gtk/wip/otte/for-master: 14/17] cssparser: Don't allow commit_token() on block EOF



commit d103fb3119cdf4624d6c5d1e0a0d8bce23d0fc85
Author: Benjamin Otte <otte redhat com>
Date:   Fri May 10 17:09:59 2019 +0200

    cssparser: Don't allow commit_token() on block EOF
    
    When we're at the end of a block and gtk_css_parser_get_token() returns
    NULL, gtk_css_parser_commit_token() still consumed the next token.
    
    It does not anymore.
    
    This does not affect the CSS parser, but it exposes issues with the
    render parser, which previously just consumed too many closing } tokens
    in the past.

 gtk/css/gtkcssparser.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/gtk/css/gtkcssparser.c b/gtk/css/gtkcssparser.c
index 2ead2e09af..5ba0997b4d 100644
--- a/gtk/css/gtkcssparser.c
+++ b/gtk/css/gtkcssparser.c
@@ -335,7 +335,9 @@ gtk_css_parser_consume_token (GtkCssParser *self)
   /* unpreserved tokens MUST be consumed via start_block() */
   g_assert (gtk_css_token_is_preserved (&self->token, NULL));
 
-  gtk_css_token_clear (&self->token);
+  /* Don't consume any tokens at the end of a block */
+  if (!gtk_css_token_is (gtk_css_parser_peek_token (self), GTK_CSS_TOKEN_EOF))
+    gtk_css_token_clear (&self->token);
 }
 
 void
@@ -435,7 +437,15 @@ gtk_css_parser_end_block (GtkCssParser *self)
   else
     {
       g_array_set_size (self->blocks, self->blocks->len - 1);
-      gtk_css_parser_skip (self);
+      if (gtk_css_token_is_preserved (&self->token, NULL))
+        {
+          gtk_css_token_clear (&self->token);
+        }
+      else
+        {
+          gtk_css_parser_start_block (self);
+          gtk_css_parser_end_block (self);
+        }
     }
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]