summaryrefslogtreecommitdiff
path: root/libavcodec/webvttdec.c
diff options
context:
space:
mode:
authorRicardo Constantino <wiiaboo@gmail.com>2015-10-11 17:11:01 +0100
committerClément Bœsch <u@pkh.me>2015-10-12 22:04:05 +0200
commit53886d6955134be8acc26f336bdf068fd970669d (patch)
treec373a9fad3eeab639eceadb4889622368516f4ee /libavcodec/webvttdec.c
parent329bd254750f3f90f4cf4a50f177aeb12458d449 (diff)
downloadffmpeg-53886d6955134be8acc26f336bdf068fd970669d.tar.gz
avcodec/webvttdec: Deal with WebVTT escapes
Bare ampersand characters are still accepted, even though out-of-spec. Also fixes adjacent tags not being parsed. Fixes trac #4915 Signed-off-by: Ricardo Constantino <wiiaboo@gmail.com>
Diffstat (limited to 'libavcodec/webvttdec.c')
-rw-r--r--libavcodec/webvttdec.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/libavcodec/webvttdec.c b/libavcodec/webvttdec.c
index 1284a172c4..fb1a422124 100644
--- a/libavcodec/webvttdec.c
+++ b/libavcodec/webvttdec.c
@@ -37,11 +37,14 @@ static const struct {
{"<b>", "{\\b1}"}, {"</b>", "{\\b0}"},
{"<u>", "{\\u1}"}, {"</u>", "{\\u0}"},
{"{", "\\{"}, {"}", "\\}"}, // escape to avoid ASS markup conflicts
+ {"&gt;", ">"}, {"&lt;", "<"},
+ {"&lrm;", ""}, {"&rlm;", ""}, // FIXME: properly honor bidi marks
+ {"&amp;", "&"}, {"&nbsp;", "\\h"},
};
static int webvtt_event_to_ass(AVBPrint *buf, const char *p)
{
- int i, skip = 0;
+ int i, again, skip = 0;
while (*p) {
@@ -51,12 +54,18 @@ static int webvtt_event_to_ass(AVBPrint *buf, const char *p)
if (!strncmp(p, from, len)) {
av_bprintf(buf, "%s", webvtt_tag_replace[i].to);
p += len;
+ again = 1;
break;
}
}
if (!*p)
break;
+ if (again) {
+ again = 0;
+ skip = 0;
+ continue;
+ }
if (*p == '<')
skip = 1;
else if (*p == '>')