From b90802f7e44f280b9ea233cf71692704e5b52651 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 21 May 2014 19:17:21 +0200 Subject: [PATCH] css: Actually break at end of the string Introduced in 65c4c1555d0634c063c3aa354620de260e4aaf7f. Found by gnome-continuous running the testsuite. Includes fixing a broken test in the testsuite. --- gtk/gtkcssparser.c | 5 ++-- gtk/gtkcssstringvalue.c | 5 +++- testsuite/css/parser/Makefile.am | 1 + testsuite/css/parser/string-values.ref.css | 27 ++++++++++++++++++++++ 4 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 testsuite/css/parser/string-values.ref.css diff --git a/gtk/gtkcssparser.c b/gtk/gtkcssparser.c index de78ae6fb1..644592bc92 100644 --- a/gtk/gtkcssparser.c +++ b/gtk/gtkcssparser.c @@ -1025,13 +1025,13 @@ _gtk_css_print_string (GString *str, g_string_append_c (str, '"'); do { - len = strcspn (string, "\"\n\r\f"); + len = strcspn (string, "\\\"\n\r\f"); g_string_append_len (str, string, len); string += len; switch (*string) { case '\0': - break; + goto out; case '\n': g_string_append (str, "\\A "); break; @@ -1054,6 +1054,7 @@ _gtk_css_print_string (GString *str, string++; } while (*string); +out: g_string_append_c (str, '"'); } diff --git a/gtk/gtkcssstringvalue.c b/gtk/gtkcssstringvalue.c index 5da9fefbcc..56ccc692e2 100644 --- a/gtk/gtkcssstringvalue.c +++ b/gtk/gtkcssstringvalue.c @@ -88,7 +88,7 @@ gtk_css_value_ident_print (const GtkCssValue *value, switch (*string) { case '\0': - break; + goto out; case '\n': g_string_append (str, "\\A "); break; @@ -113,6 +113,9 @@ gtk_css_value_ident_print (const GtkCssValue *value, } string++; } while (*string); + +out: + ; } static const GtkCssValueClass GTK_CSS_VALUE_STRING = { diff --git a/testsuite/css/parser/Makefile.am b/testsuite/css/parser/Makefile.am index 846b93833e..084a340a3d 100644 --- a/testsuite/css/parser/Makefile.am +++ b/testsuite/css/parser/Makefile.am @@ -334,6 +334,7 @@ test_data = \ single-slash.errors\ single-slash.ref.css \ string-values.css \ + string-values.ref.css \ test.png \ transition.css \ transition.ref.css \ diff --git a/testsuite/css/parser/string-values.ref.css b/testsuite/css/parser/string-values.ref.css new file mode 100644 index 0000000000..491a023b41 --- /dev/null +++ b/testsuite/css/parser/string-values.ref.css @@ -0,0 +1,27 @@ +n { + font-family: "\A "; +} + +r { + font-family: "\C "; +} + +f { + font-family: "\D "; +} + +a { + font-family: "\""; +} + +b { + font-family: "'"; +} + +c { + font-family: "'"; +} + +d { + font-family: "\\"; +}