gst/gststructure.c: Make sure that string fields in structures/taglists contain valid...
authorTim-Philipp Müller <tim@centricular.net>
Tue, 21 Mar 2006 14:24:41 +0000 (14:24 +0000)
committerTim-Philipp Müller <tim@centricular.net>
Tue, 21 Mar 2006 14:24:41 +0000 (14:24 +0000)
Original commit message from CVS:
* gst/gststructure.c: (gst_structure_id_set_value):
Make sure that string fields in structures/taglists
contain valid UTF-8 - we don't want to pass rubbish to
applications because of a buggy plugin (cp. #334167).

ChangeLog
gst/gststructure.c

index 4175dfd..9aaf26e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,11 @@
-2006-03-21  Edward Hervey  <edward@fluendo.com>
+2006-03-21  Tim-Philipp Müller  <tim at centricular dot net>
 
-       reviewed by: <delete if not using a buddy>
+       * gst/gststructure.c: (gst_structure_id_set_value):
+         Make sure that string fields in structures/taglists
+         contain valid UTF-8 - we don't want to pass rubbish to
+         applications because of a buggy plugin (cp. #334167).
+
+2006-03-21  Edward Hervey  <edward@fluendo.com>
 
        * gst/gstbin.c: (gst_bin_dispose), (gst_bin_provide_clock_func),
        (gst_bin_handle_message_func):
index 0d3cbc2..04a6a99 100644 (file)
@@ -388,6 +388,20 @@ gst_structure_id_set_value (GstStructure * structure,
   g_return_if_fail (G_IS_VALUE (value));
   g_return_if_fail (IS_MUTABLE (structure));
 
+  /* if someones disables GST_DEBUG output, they probably do it for
+   * performance reasons, so skip the UTF-8 check here as well then */
+#ifndef GST_DISABLE_GST_DEBUG
+  if (G_VALUE_HOLDS_STRING (value)) {
+    const gchar *s;
+
+    s = g_value_get_string (value);
+    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));
+    }
+  }
+#endif
+
   gsfield.name = field;
   gst_value_init_and_copy (&gsfield.value, value);