From: Vincent Penquerc'h Date: Thu, 29 Oct 2015 12:04:31 +0000 (+0000) Subject: dash_mpd: restrict segment template format strings to %0[0-9]*d as per spec X-Git-Tag: 1.19.3~507^2~7720 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7443f35249572d237ef16859969fb11126ea0184;p=platform%2Fupstream%2Fgstreamer.git dash_mpd: restrict segment template format strings to %0[0-9]*d as per spec https://bugzilla.gnome.org/show_bug.cgi?id=751735 --- diff --git a/ext/dash/gstmpdparser.c b/ext/dash/gstmpdparser.c index 7279d72..953e207 100644 --- a/ext/dash/gstmpdparser.c +++ b/ext/dash/gstmpdparser.c @@ -2968,23 +2968,19 @@ validate_format (const gchar * format) return FALSE; p++; - /* the spec mandates a format like %0[width]d - But we also accept %d, because it doesn't hurt us - */ - /* Following the %, if we have a number, it must start with 0 */ - if (g_ascii_isdigit (p[0]) && p[0] != '0') + /* the spec mandates a format like %0[width]d */ + /* Following the %, we must have a 0 */ + if (p[0] != '0') return FALSE; - /* Following the % must be a number, or any of d, x or u. - * x and u are not part of the spec, but don't hurt us + /* Following the % must be a number starting with 0 */ while (g_ascii_isdigit (*p)) p++; - /* After any 0 and alphanumeric values, there must be - * an d, x or u. + /* After any 0 and alphanumeric values, there must be a d. */ - if (p[0] != 'd' && p[0] != 'x' && p[0] != 'u') + if (p[0] != 'd') return FALSE; p++; @@ -3020,10 +3016,10 @@ promote_format_to_uint64 (const gchar * format) p++; } - /* After any 0 and alphanumeric values, there must be - * an d, x or u. Otherwise validation would have failed + /* After any 0 and alphanumeric values, there must be a d. + * Otherwise validation would have failed */ - g_assert (p[0] == 'd' || p[0] == 'x' || p[0] == 'u'); + g_assert (p[0] == 'd'); promoted_format = g_strdup_printf ("%.*s" G_GINT64_MODIFIER "%s", (gint) (p - format), diff --git a/tests/check/elements/dash_mpd.c b/tests/check/elements/dash_mpd.c index ad6694c..633beb2 100644 --- a/tests/check/elements/dash_mpd.c +++ b/tests/check/elements/dash_mpd.c @@ -2488,7 +2488,7 @@ GST_START_TEST (dash_mpdparser_template_parsing) {"TestMedia$Bandwidth$$$test", "TestMedia2500$test"}, /* Bandwidth identifier */ {"TestMedia$Time$", "TestMedia100"}, /* Time identifier */ {"TestMedia$Time", NULL}, /* Identifier not finished with $ */ - {"Time$Time%d$", "Time100"}, /* usage of %d (no width) */ + {"Time$Time%d$", NULL}, /* usage of %d (no width) */ {"Time$Time%0d$", "Time100"}, /* usage of format smaller than number of digits */ {"Time$Time%01d$", "Time100"}, /* usage of format smaller than number of digits */ {"Time$Time%05d$", "Time00100"}, /* usage of format bigger than number of digits */ @@ -2503,10 +2503,10 @@ GST_START_TEST (dash_mpdparser_template_parsing) {"$Bandwidth1$", NULL}, /* incorrect identifier */ {"$Number1$", NULL}, /* incorrect identifier */ {"$RepresentationID%01d$", NULL}, /* incorrect format: RepresentationID does not support formatting */ - {"Time$Time%05u$", "Time00100"}, /* %u format */ - {"Time$Time%05x$", "Time00064"}, /* %x format */ - {"Time$Time%05utest$", "Time00100test"}, /* %u format followed by text */ - {"Time$Time%05xtest$", "Time00064test"}, /* %x format followed by text */ + {"Time$Time%05u$", NULL}, /* %u format */ + {"Time$Time%05x$", NULL}, /* %x format */ + {"Time$Time%05utest$", NULL}, /* %u format followed by text */ + {"Time$Time%05xtest$", NULL}, /* %x format followed by text */ {"Time$Time%05xtest%$", NULL}, /* second % character in format */ };