From c7fc3dc0e83bffc58352fdb9ecc8b5596b269e80 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Thu, 26 Oct 2006 08:49:52 +0000 Subject: [PATCH] gst/gststructure.c: If someone tries to set a non-UTF8 string field on a structure, don't just print a warning, but a... Original commit message from CVS: * 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. --- ChangeLog | 10 ++++++++++ gst/gststructure.c | 1 + tests/check/gst/gsttag.c | 20 ++++++++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/ChangeLog b/ChangeLog index eeb2f99..563d13c 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 4cadad9..9517dbf 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 9f1afa2..c634ad4 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; } -- 2.7.4