From: Oneric <oneric@oneric.de> To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH v2 2/3] avcodec/{ass, webvttdec}: fix handling of backslashes Date: Sun, 10 Dec 2023 17:37:14 +0100 Message-ID: <20231210163715.4016-3-oneric@oneric.de> (raw) In-Reply-To: <20231210163715.4016-1-oneric@oneric.de> 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. --- “” --- libavcodec/ass.c | 9 ++++++++- libavcodec/webvttdec.c | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/libavcodec/ass.c b/libavcodec/ass.c index 5058dc8337..a68d3568b4 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 diff --git a/libavcodec/webvttdec.c b/libavcodec/webvttdec.c index 990d150f16..6e55bc5499 100644 --- a/libavcodec/webvttdec.c +++ b/libavcodec/webvttdec.c @@ -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"}, -- 2.39.2 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2023-12-10 16:38 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-12-10 16:37 [FFmpeg-devel] [PATCH v2 0/3] Fix some active sequences in subtitles Oneric 2023-12-10 16:37 ` [FFmpeg-devel] [PATCH v2 1/3] avcodec/webvttdec: honour bidi marks Oneric 2023-12-10 16:37 ` Oneric [this message] 2023-12-10 16:37 ` [FFmpeg-devel] [PATCH v2 3/3] avcodec/{ass, webvttdec}: more portable curly brace escapes Oneric 2023-12-28 0:55 ` [FFmpeg-devel] [PATCH v2 0/3] Fix some active sequences in subtitles Oneric 2024-01-10 0:25 ` Oneric
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20231210163715.4016-3-oneric@oneric.de \ --to=oneric@oneric.de \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git