gst-libs/gst/tag/gstvorbistag.c: Parse date strings in vorbis comments that have...
authorRené Stadler <mail@renestadler.de>
Sun, 25 Feb 2007 23:51:03 +0000 (23:51 +0000)
committerTim-Philipp Müller <tim@centricular.net>
Sun, 25 Feb 2007 23:51:03 +0000 (23:51 +0000)
Original commit message from CVS:
Patch by: René Stadler <mail at renestadler de>
* gst-libs/gst/tag/gstvorbistag.c: (gst_vorbis_tag_add):
Parse date strings in vorbis comments that have an invalid (zero)
month or day (#410396).
* tests/check/libs/tag.c: (GST_START_TEST):
Test case for the above.

ChangeLog
gst-libs/gst/tag/gstvorbistag.c
tests/check/libs/tag.c

index 3dc9c88..b338ee6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2007-02-25  Tim-Philipp Müller  <tim at centricular dot net>
+
+       Patch by: René Stadler <mail at renestadler de>
+
+       * gst-libs/gst/tag/gstvorbistag.c: (gst_vorbis_tag_add):
+         Parse date strings in vorbis comments that have an invalid (zero)
+         month or day (#410396).
+
+       * tests/check/libs/tag.c: (GST_START_TEST):
+         Test case for the above.
+
 2007-02-24  Tim-Philipp Müller  <tim at centricular dot net>
 
        Patch by: Loïc Minier <lool+gnome at via ecp fr>
index 226a463..e878d33 100644 (file)
@@ -254,6 +254,12 @@ gst_vorbis_tag_add (GstTagList * list, const gchar * tag, const gchar * value)
           }
         }
 
+        if (y != 0 && m == 0 && d == 0) {
+          /* accept dates of the form 2007-00-00 as 2007-01-01 */
+          m = 1;
+          d = 1;
+        }
+
         /* date might be followed by a time */
         if ((*check == '\0' || g_ascii_isspace (*check)) && y != 0 &&
             g_date_valid_dmy (d, m, y)) {
index 11252f2..5a799cd 100644 (file)
@@ -515,6 +515,21 @@ GST_START_TEST (test_vorbis_tags)
     g_date_free (date);
     gst_tag_list_free (list);
   }
+
+  /* check date with month/day of 00-00 */
+  {
+    GDate *date = NULL;
+
+    list = gst_tag_list_new ();
+    gst_vorbis_tag_add (list, "DATE", "1992-00-00");
+
+    fail_unless (gst_tag_list_get_date_index (list, GST_TAG_DATE, 0, &date));
+    fail_unless (date != NULL);
+    fail_unless (g_date_get_year (date) == 1992);
+
+    g_date_free (date);
+    gst_tag_list_free (list);
+  }
 }
 
 GST_END_TEST;