From 5f5d3a9d820004e88b43ff20884d604b4620e47e Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 30 Jul 2014 18:23:20 +0200 Subject: [PATCH] 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 + testsuite/css/parser/border-infloop-3.12.ref.css | 0 5 files changed, 14 insertions(+) create mode 100644 testsuite/css/parser/border-infloop-3.12.css create mode 100644 testsuite/css/parser/border-infloop-3.12.errors create mode 100644 testsuite/css/parser/border-infloop-3.12.ref.css diff --git a/gtk/gtkcssshorthandpropertyimpl.c b/gtk/gtkcssshorthandpropertyimpl.c index 06c20ddcd4..c81e2c4703 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 c7754ce39a..f44f7757dc 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 0000000000..62acb3e69e --- /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 0000000000..808dde302a --- /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 0000000000..e69de29bb2