mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-03-02 18:48:27 +00:00
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>
This commit is contained in:
parent
329bd25475
commit
53886d6955
@ -37,11 +37,14 @@ static const struct {
|
|||||||
{"<b>", "{\\b1}"}, {"</b>", "{\\b0}"},
|
{"<b>", "{\\b1}"}, {"</b>", "{\\b0}"},
|
||||||
{"<u>", "{\\u1}"}, {"</u>", "{\\u0}"},
|
{"<u>", "{\\u1}"}, {"</u>", "{\\u0}"},
|
||||||
{"{", "\\{"}, {"}", "\\}"}, // escape to avoid ASS markup conflicts
|
{"{", "\\{"}, {"}", "\\}"}, // escape to avoid ASS markup conflicts
|
||||||
|
{">", ">"}, {"<", "<"},
|
||||||
|
{"‎", ""}, {"‏", ""}, // FIXME: properly honor bidi marks
|
||||||
|
{"&", "&"}, {" ", "\\h"},
|
||||||
};
|
};
|
||||||
|
|
||||||
static int webvtt_event_to_ass(AVBPrint *buf, const char *p)
|
static int webvtt_event_to_ass(AVBPrint *buf, const char *p)
|
||||||
{
|
{
|
||||||
int i, skip = 0;
|
int i, again, skip = 0;
|
||||||
|
|
||||||
while (*p) {
|
while (*p) {
|
||||||
|
|
||||||
@ -51,12 +54,18 @@ static int webvtt_event_to_ass(AVBPrint *buf, const char *p)
|
|||||||
if (!strncmp(p, from, len)) {
|
if (!strncmp(p, from, len)) {
|
||||||
av_bprintf(buf, "%s", webvtt_tag_replace[i].to);
|
av_bprintf(buf, "%s", webvtt_tag_replace[i].to);
|
||||||
p += len;
|
p += len;
|
||||||
|
again = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!*p)
|
if (!*p)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
if (again) {
|
||||||
|
again = 0;
|
||||||
|
skip = 0;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (*p == '<')
|
if (*p == '<')
|
||||||
skip = 1;
|
skip = 1;
|
||||||
else if (*p == '>')
|
else if (*p == '>')
|
||||||
|
Loading…
Reference in New Issue
Block a user