diff --git a/ChangeLog b/ChangeLog index eeb2f998a5..563d13cc06 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2006-10-26 Tim-Philipp Müller + + * gst/gststructure.c: (gst_structure_id_set_value): + If someone tries to set a non-UTF8 string field on a structure, + don't just print a warning, but also ignore the request and do + not change/add that field to the structure. + + * tests/check/gst/gsttag.c: (GST_START_TEST), (gst_tag_suite): + Test for the above. + 2006-10-25 David Schleef * gst/gstinfo.c: diff --git a/gst/gststructure.c b/gst/gststructure.c index 4cadad9556..9517dbfb2c 100644 --- a/gst/gststructure.c +++ b/gst/gststructure.c @@ -400,6 +400,7 @@ gst_structure_id_set_value (GstStructure * structure, if (s != NULL && !g_utf8_validate (s, -1, NULL)) { g_warning ("Trying to set string field '%s' on structure, but string is " "not valid UTF-8. Please file a bug.", g_quark_to_string (field)); + return; } } #endif diff --git a/tests/check/gst/gsttag.c b/tests/check/gst/gsttag.c index 9f1afa2596..c634ad42fc 100644 --- a/tests/check/gst/gsttag.c +++ b/tests/check/gst/gsttag.c @@ -241,6 +241,25 @@ GST_START_TEST (test_type) GST_END_TEST; +GST_START_TEST (test_set_non_utf8_string) +{ + GstTagList *taglist; + guint8 foobar[2] = { 0xff, 0x00 }; /* not UTF-8 */ + + taglist = gst_tag_list_new (); + fail_unless (taglist != NULL); + + ASSERT_WARNING (gst_tag_list_add (taglist, GST_TAG_MERGE_APPEND, + GST_TAG_ARTIST, (gchar *) foobar, NULL)); + + /* That string field with a non-UTF8 string should not have been added */ + fail_unless (gst_tag_list_is_empty (taglist)); + + gst_tag_list_free (taglist); +} + +GST_END_TEST; + static Suite * gst_tag_suite (void) { @@ -251,6 +270,7 @@ gst_tag_suite (void) tcase_add_test (tc_chain, test_merge); tcase_add_test (tc_chain, test_date_tags); tcase_add_test (tc_chain, test_type); + tcase_add_test (tc_chain, test_set_non_utf8_string); return s; }