mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
structure: Handle trailing comas in serialized structs
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/717>
This commit is contained in:
parent
783e19b04c
commit
978ba72bdd
2 changed files with 39 additions and 0 deletions
|
@ -2337,6 +2337,14 @@ priv_gst_structure_parse_fields (gchar * str, gchar ** end,
|
||||||
&& g_ascii_isspace (r[1]))))
|
&& g_ascii_isspace (r[1]))))
|
||||||
r++;
|
r++;
|
||||||
|
|
||||||
|
/* Trailing comma */
|
||||||
|
if (*r == '\0') {
|
||||||
|
break;
|
||||||
|
} else if (*r == ';') {
|
||||||
|
r++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
memset (&field, 0, sizeof (field));
|
memset (&field, 0, sizeof (field));
|
||||||
if (G_UNLIKELY (!gst_structure_parse_field (r, &r, &field))) {
|
if (G_UNLIKELY (!gst_structure_parse_field (r, &r, &field))) {
|
||||||
GST_WARNING ("Failed to parse field, r=%s", r);
|
GST_WARNING ("Failed to parse field, r=%s", r);
|
||||||
|
|
|
@ -161,6 +161,37 @@ GST_START_TEST (test_from_string)
|
||||||
fail_unless_equals_int (g_value_get_boolean (val), TRUE);
|
fail_unless_equals_int (g_value_get_boolean (val), TRUE);
|
||||||
gst_structure_free (structure);
|
gst_structure_free (structure);
|
||||||
|
|
||||||
|
/* Test trailing comas */
|
||||||
|
s = "test-string,";
|
||||||
|
structure = gst_structure_from_string (s, NULL);
|
||||||
|
fail_if (structure == NULL, "Could not get structure from string %s", s);
|
||||||
|
gst_structure_free (structure);
|
||||||
|
|
||||||
|
s = "test-string,;";
|
||||||
|
structure = gst_structure_from_string (s, NULL);
|
||||||
|
fail_if (structure == NULL, "Could not get structure from string %s", s);
|
||||||
|
gst_structure_free (structure);
|
||||||
|
|
||||||
|
s = "test-string,value=true,";
|
||||||
|
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_BOOLEAN (val));
|
||||||
|
fail_unless_equals_int (g_value_get_boolean (val), TRUE);
|
||||||
|
gst_structure_free (structure);
|
||||||
|
|
||||||
|
s = "test-string,value=true,;";
|
||||||
|
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_BOOLEAN (val));
|
||||||
|
fail_unless_equals_int (g_value_get_boolean (val), TRUE);
|
||||||
|
gst_structure_free (structure);
|
||||||
|
|
||||||
|
s = "test-string,value=true,,";
|
||||||
|
structure = gst_structure_from_string (s, NULL);
|
||||||
|
fail_unless (structure == NULL, "Created structure from string %s", s);
|
||||||
|
|
||||||
/* Tests for flagset deserialisation */
|
/* Tests for flagset deserialisation */
|
||||||
s = "foobar,value=0010:ffff";
|
s = "foobar,value=0010:ffff";
|
||||||
structure = gst_structure_from_string (s, NULL);
|
structure = gst_structure_from_string (s, NULL);
|
||||||
|
|
Loading…
Reference in a new issue