[gtk+] css: Don't infloop when parsing broken borders



commit 5f5d3a9d820004e88b43ff20884d604b4620e47e
Author: Benjamin Otte <otte redhat com>
Date:   Wed Jul 30 18:23:20 2014 +0200

    css: Don't infloop when parsing broken borders
    
    There was an infinite loop when parsing invalid text after having parsed
    a color in the border shorthand. See attached testcase for an example.

 gtk/gtkcssshorthandpropertyimpl.c                |    7 +++++++
 testsuite/css/parser/Makefile.am                 |    3 +++
 testsuite/css/parser/border-infloop-3.12.css     |    3 +++
 testsuite/css/parser/border-infloop-3.12.errors  |    1 +
 4 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkcssshorthandpropertyimpl.c b/gtk/gtkcssshorthandpropertyimpl.c
index 06c20dd..c81e2c4 100644
--- a/gtk/gtkcssshorthandpropertyimpl.c
+++ b/gtk/gtkcssshorthandpropertyimpl.c
@@ -353,6 +353,13 @@ parse_border_side (GtkCssShorthandProperty  *shorthand,
         if (values[2] == NULL)
           return FALSE;
       }
+    else
+      {
+        /* We parsed and there's still stuff left?
+         * Pretend we didn't notice and let the normal code produce
+         * a 'junk at end of value' error */
+        break;
+      }
   }
   while (!value_is_done_parsing (parser));
 
diff --git a/testsuite/css/parser/Makefile.am b/testsuite/css/parser/Makefile.am
index c7754ce..f44f775 100644
--- a/testsuite/css/parser/Makefile.am
+++ b/testsuite/css/parser/Makefile.am
@@ -178,6 +178,9 @@ test_data = \
        border.ref.css \
        border-color-currentcolor.css \
        border-color-currentcolor.ref.css \
+       border-infloop-3.12.css \
+       border-infloop-3.12.errors \
+       border-infloop-3.12.ref.css \
        border-radius.css \
        border-radius.errors \
        border-radius.ref.css \
diff --git a/testsuite/css/parser/border-infloop-3.12.css b/testsuite/css/parser/border-infloop-3.12.css
new file mode 100644
index 0000000..62acb3e
--- /dev/null
+++ b/testsuite/css/parser/border-infloop-3.12.css
@@ -0,0 +1,3 @@
+* {
+  border-bottom: tomato dot;
+}
diff --git a/testsuite/css/parser/border-infloop-3.12.errors b/testsuite/css/parser/border-infloop-3.12.errors
new file mode 100644
index 0000000..808dde3
--- /dev/null
+++ b/testsuite/css/parser/border-infloop-3.12.errors
@@ -0,0 +1 @@
+border-infloop-3.12.css:2: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
diff --git a/testsuite/css/parser/border-infloop-3.12.ref.css 
b/testsuite/css/parser/border-infloop-3.12.ref.css
new file mode 100644
index 0000000..e69de29


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