aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/ass.c
diff options
context:
space:
mode:
authorOneric <oneric@oneric.de>2024-02-19 22:42:25 +0100
committerStefano Sabatini <stefasab@gmail.com>2024-04-06 09:24:47 +0200
commitbaa64fa4e66465c63f84baaae204734aa19efb3f (patch)
tree63991fc382cbefe149fb4f4b2bc695c6c2f10aec /libavcodec/ass.c
parent7b8b4cdd9654ead881bc61a0b62e1586b473f843 (diff)
downloadffmpeg-baa64fa4e66465c63f84baaae204734aa19efb3f.tar.gz
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.
Diffstat (limited to 'libavcodec/ass.c')
-rw-r--r--libavcodec/ass.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/libavcodec/ass.c b/libavcodec/ass.c
index 5ff4ac8e07..c5abf15122 100644
--- a/libavcodec/ass.c
+++ b/libavcodec/ass.c
@@ -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