From 88e94fc2781804e383dbe1e6c8b727104ecdf83c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ren=C3=A9=20Stadler?= Date: Sun, 25 Feb 2007 23:51:03 +0000 Subject: [PATCH] gst-libs/gst/tag/gstvorbistag.c: Parse date strings in vorbis comments that have an invalid (zero) month or day (#410... MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Original commit message from CVS: Patch by: René Stadler * 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 | 11 +++++++++++ gst-libs/gst/tag/gstvorbistag.c | 6 ++++++ tests/check/libs/tag.c | 15 +++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/ChangeLog b/ChangeLog index 3dc9c88..b338ee6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2007-02-25 Tim-Philipp Müller + + Patch by: René Stadler + + * 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 Patch by: Loïc Minier diff --git a/gst-libs/gst/tag/gstvorbistag.c b/gst-libs/gst/tag/gstvorbistag.c index 226a463..e878d33 100644 --- a/gst-libs/gst/tag/gstvorbistag.c +++ b/gst-libs/gst/tag/gstvorbistag.c @@ -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)) { diff --git a/tests/check/libs/tag.c b/tests/check/libs/tag.c index 11252f2..5a799cd 100644 --- a/tests/check/libs/tag.c +++ b/tests/check/libs/tag.c @@ -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; -- 2.7.4