From 9d2825ccffd2ca7dd1eed08f35a51e056393063f Mon Sep 17 00:00:00 2001 From: Chris White Date: Thu, 24 Dec 2020 14:06:29 -0500 Subject: [PATCH] structure: add tests of deserializing strings with escapes Shows the issue described in Part-of: --- tests/check/gst/gststructure.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/check/gst/gststructure.c b/tests/check/gst/gststructure.c index 357c3a4ee4..d9531ec4da 100644 --- a/tests/check/gst/gststructure.c +++ b/tests/check/gst/gststructure.c @@ -223,6 +223,21 @@ GST_START_TEST (test_from_string) ASSERT_CRITICAL (structure = gst_structure_from_string (s, NULL)); fail_unless (structure == NULL, "Could not get structure from string %s", s); + /* Test that escaping works both with and without a type */ + s = "foo/bar, value=\"raven \\\"nevermore\\\"\""; + structure = gst_structure_from_string (s, NULL); + fail_if (structure == NULL, "Could not get structure from string %s", s); + fail_unless ((val = gst_structure_get_value (structure, "value")) != NULL); + fail_unless (G_VALUE_HOLDS_STRING (val)); + gst_structure_free (structure); + + s = "foo/bar, value=(string)\"raven \\\"nevermore\\\"\""; + structure = gst_structure_from_string (s, NULL); + fail_if (structure == NULL, "Could not get structure from string %s", s); + fail_unless ((val = gst_structure_get_value (structure, "value")) != NULL); + fail_unless (G_VALUE_HOLDS_STRING (val)); + gst_structure_free (structure); + /* make sure we bail out correctly in case of an error or if parsing fails */ s = "***foo***, abc=(boolean)false"; structure = gst_structure_from_string (s, NULL);