gst/tags/gstvorbistag.c: make sure parsed vorbis comments are properly encoded in...
authorChristophe Fergeau <teuf@gnome.org>
Wed, 9 Jun 2004 22:12:33 +0000 (22:12 +0000)
committerChristophe Fergeau <teuf@gnome.org>
Wed, 9 Jun 2004 22:12:33 +0000 (22:12 +0000)
Original commit message from CVS:
2004-06-10  Christophe Fergeau  <teuf@gnome.org>

* gst/tags/gstvorbistag.c: (gst_vorbis_tag_add): make sure parsed
vorbis comments are properly encoded in UTF-8 before adding them
to a GstTagList

ChangeLog
gst/tags/gstvorbistag.c

index 9498000..bf4711a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2004-06-10  Christophe Fergeau  <teuf@gnome.org>
+
+       * gst/tags/gstvorbistag.c: (gst_vorbis_tag_add): make sure parsed 
+         vorbis comments are properly encoded in UTF-8 before adding them
+         to a GstTagList
+
 2004-06-09  Benjamin Otte  <otte@gnome.org>
 
        * ext/alsa/gstalsa.c: (add_channels):
index 18ce40a..986a7bc 100644 (file)
@@ -319,9 +319,19 @@ gst_vorbis_tag_add (GstTagList * list, const gchar * tag, const gchar * value)
         gst_tag_list_add (list, GST_TAG_MERGE_APPEND, gst_tag, tmp, NULL);
       }
       break;
-    case G_TYPE_STRING:
-      gst_tag_list_add (list, GST_TAG_MERGE_APPEND, gst_tag, value, NULL);
+    case G_TYPE_STRING:{
+      gchar *valid;
+
+      if (!g_utf8_validate (value, -1, (const gchar **) &valid)) {
+        valid = g_strndup (value, valid - value);
+        g_warning ("Invalid vorbis comment tag, truncated it to %s\n", valid);
+      } else {
+        valid = g_strdup (value);
+      }
+      gst_tag_list_add (list, GST_TAG_MERGE_APPEND, gst_tag, valid, NULL);
+      g_free (valid);
       break;
+    }
     case G_TYPE_DOUBLE:
       gst_tag_list_add (list, GST_TAG_MERGE_APPEND, gst_tag, g_strtod (value,
               NULL), NULL);