gst-libs/gst/tag/gstvorbistag.c: Parse date strings in vorbis comments that have an invalid (zero) month or day (#410...

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.
This commit is contained in:
René Stadler 2007-02-25 23:51:03 +00:00 committed by Tim-Philipp Müller
parent 2770d0fbea
commit 88e94fc278
3 changed files with 32 additions and 0 deletions

View file

@ -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>

View 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)) {

View 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;