mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2024-09-20 05:16:38 +00:00
avcodec/ass,webvttdec: fix handling of backslashes
Backslashes cannot be escaped by a backslash in any ASS renderer, but unless followed by specific characters it is just printed out. Insert a word-joiner character after a backslash to break up active sequences without changing the visual output.
This commit is contained in:
parent
7b8b4cdd96
commit
baa64fa4e6
@ -183,9 +183,16 @@ void ff_ass_bprint_text_event(AVBPrint *buf, const char *p, int size,
|
||||
|
||||
/* standard ASS escaping so random characters don't get mis-interpreted
|
||||
* as ASS */
|
||||
} else if (!keep_ass_markup && strchr("{}\\", *p)) {
|
||||
} else if (!keep_ass_markup && strchr("{}", *p)) {
|
||||
av_bprintf(buf, "\\%c", *p);
|
||||
|
||||
/* append word-joiner U+2060 as UTF-8 to break up sequences like \N */
|
||||
} else if (!keep_ass_markup && *p == '\\') {
|
||||
if (p_end - p <= 3 || strncmp(p + 1, "\xe2\x81\xa0", 3))
|
||||
av_bprintf(buf, "\\\xe2\x81\xa0");
|
||||
else
|
||||
av_bprintf(buf, "\\");
|
||||
|
||||
/* some packets might end abruptly (no \0 at the end, like for example
|
||||
* in some cases of demuxing from a classic video container), some
|
||||
* might be terminated with \n or \r\n which we have to remove (for
|
||||
|
@ -37,7 +37,7 @@ static const struct {
|
||||
{"<i>", "{\\i1}"}, {"</i>", "{\\i0}"},
|
||||
{"<b>", "{\\b1}"}, {"</b>", "{\\b0}"},
|
||||
{"<u>", "{\\u1}"}, {"</u>", "{\\u0}"},
|
||||
{"{", "\\{"}, {"}", "\\}"}, // escape to avoid ASS markup conflicts
|
||||
{"{", "\\{"}, {"}", "\\}"}, {"\\", "\\\xe2\x81\xa0"}, // escape to avoid ASS markup conflicts
|
||||
{">", ">"}, {"<", "<"},
|
||||
{"‎", "\xe2\x80\x8e"}, {"‏", "\xe2\x80\x8f"},
|
||||
{"&", "&"}, {" ", "\\h"},
|
||||
|
Loading…
Reference in New Issue
Block a user