diff --git a/gst/gstvalue.c b/gst/gstvalue.c index b406f50123..45cf6b47bb 100644 --- a/gst/gstvalue.c +++ b/gst/gstvalue.c @@ -3931,13 +3931,13 @@ gst_string_unwrap (const gchar * s) /* if we run into a \0 here, we definitely won't get a quote later */ if (*read == 0) goto beach; - /* else copy \X sequence */ *write++ = *read++; } - } else { - /* weird character, error */ + } else if (*read == '\0') { goto beach; + } else { + *write++ = *read++; } } /* if the string is not ending in " and zero terminated, we error */ @@ -3975,6 +3975,10 @@ gst_value_deserialize_string (GValue * dest, const gchar * s) gchar *str = gst_string_unwrap (s); if (G_UNLIKELY (!str)) return FALSE; + if (!g_utf8_validate (str, -1, NULL)) { + g_free (str); + return FALSE; + } g_value_take_string (dest, str); } diff --git a/tests/check/gst/gstvalue.c b/tests/check/gst/gstvalue.c index 3ab8387806..6ded6d27e4 100644 --- a/tests/check/gst/gstvalue.c +++ b/tests/check/gst/gstvalue.c @@ -801,21 +801,21 @@ GST_START_TEST (test_deserialize_string) "\"Hello\\ World", "\"Hello\\ World"}, { "\"\\", "\"\\"}, { "\"\\0", "\"\\0"}, { + "\"t\\303\\274t\"", "tüt"}, { + /* utf8 octal sequence */ "", ""}, /* empty strings */ { - "\"\"", ""}, /* quoted empty string -> empty string */ + "\"\"", ""}, { /* quoted empty string -> empty string */ + "\" \"", " "}, { /* allow spaces to be not escaped */ + "tüüt", "tüüt"}, /* allow special chars to be not escaped */ /* Expected FAILURES: */ { - "\"\\0\"", NULL}, /* unfinished escaped character */ - { - "\"", NULL}, /* solitary quote */ - { - "\" \"", NULL}, /* spaces must be escaped */ -#if 0 - /* FIXME 0.9: this test should fail, but it doesn't */ - { - "tüüt", NULL} /* string with special chars must be escaped */ -#endif + "\"\\0\"", NULL}, { /* unfinished escaped character */ + "\"", NULL}, { /* solitary quote */ + "\"\\380\"", NULL}, { /* invalid octal sequence */ + "\"\\344\\204\\062\"", NULL}, { + /* invalid utf8: wrong end byte */ + "\"\\344\\204\"", NULL} /* invalid utf8: wrong number of bytes */ }; guint i; GValue v = { 0, };