diff --git a/ext/dash/gstmpdparser.c b/ext/dash/gstmpdparser.c index ed539021df..7279d728f4 100644 --- a/ext/dash/gstmpdparser.c +++ b/ext/dash/gstmpdparser.c @@ -2968,16 +2968,19 @@ validate_format (const gchar * format) return FALSE; p++; - /* Following the % must be a 0, or any of d, x or u. + /* 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') + 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 */ - if (p[0] == '0') { + while (g_ascii_isdigit (*p)) p++; - while (g_ascii_isdigit (*p)) - p++; - } - /* After any 0 and alphanumeric values, there must be * an d, x or u. */ diff --git a/tests/check/elements/dash_mpd.c b/tests/check/elements/dash_mpd.c index 2ca398b49b..ad6694cb3b 100644 --- a/tests/check/elements/dash_mpd.c +++ b/tests/check/elements/dash_mpd.c @@ -2488,10 +2488,13 @@ 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%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 */ {"Time$Time%05dtest$", "Time00100test"}, /* usage extra text in format */ + {"Time$Time%3d$", NULL}, /* incorrect format: width does not start with 0 */ + {"Time$Time%0-4d$", NULL}, /* incorrect format: width is not a number */ {"Time$Time%0$", NULL}, /* incorrect format: no d, x or u */ {"Time$Time1%01d$", NULL}, /* incorrect format: does not start with % after identifier */ {"$Bandwidth%/init.mp4v", NULL}, /* incorrect identifier: not finished with $ */