summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-03-22 10:04:57 +0100
committerwm4 <wm4@nowhere>2013-03-31 20:11:43 +0200
commit68c326891d48427d673fa6a8069500dcb25b6eb8 (patch)
tree3f0031830c0ef028d1179635e1189fb21bc3074a
parentd29915d067582a8fe307b67f7ad9aba2b05bb710 (diff)
downloadlibass-68c326891d48427d673fa6a8069500dcb25b6eb8.tar.bz2
libass-68c326891d48427d673fa6a8069500dcb25b6eb8.tar.xz
Ignore junk in nested \t tags
Normally, junk between tags is ignored. But unlike vsfilter, libass doesn't do that inside \t tags. So the following fails and will never actually switch the color: {\t(1000,1000,(\c&HFF0000&))} (The '(' and ')' are junk, and are not covered by any ASS documentation.) Instead expecting that the last parameter to \t (the parameter that takes nested tags) starts with '\', turn it around and assume that the first parameter that's not a number is the last parameter. (This parsing is kind of awkward because we don't do any lookahead.) Likewise, let the nested tag parsing terminate on ')' instead of checking whether a tag is started with '\'. This allows skipping junk in the middle of the nested tag, without terminating too early. (Check '}' and '\0' in case the tag is not properly terminated.)
-rw-r--r--libass/ass_parse.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/libass/ass_parse.c b/libass/ass_parse.c
index 712cd96..f2f73e5 100644
--- a/libass/ass_parse.c
+++ b/libass/ass_parse.c
@@ -625,9 +625,8 @@ char *parse_tag(ASS_Renderer *render_priv, char *p, double pwr)
double k;
skip('(');
for (cnt = 0; cnt < 3; ++cnt) {
- if (*p == '\\')
+ if (!mystrtod(&p, &v[cnt]))
break;
- mystrtod(&p, &v[cnt]);
skip(',');
}
if (cnt == 3) {
@@ -662,7 +661,7 @@ char *parse_tag(ASS_Renderer *render_priv, char *p, double pwr)
assert(delta_t != 0.);
k = pow(((double) (t - t1)) / delta_t, v3);
}
- while (*p == '\\')
+ while (*p != ')' && *p != '}' && *p != '\0')
p = parse_tag(render_priv, p, k); // maybe k*pwr ? no, specs forbid nested \t's
skip_to(')'); // in case there is some unknown tag or a comment
skipopt(')');