From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 4911342222 for ; Sun, 16 Jan 2022 18:17:17 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 431BD68ACF5; Sun, 16 Jan 2022 20:17:14 +0200 (EET) Received: from mo4-p00-ob.smtp.rzone.de (mo4-p00-ob.smtp.rzone.de [85.215.255.25]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6C00E68A64A for ; Sun, 16 Jan 2022 20:17:08 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1642357027; s=strato-dkim-0002; d=oneric.de; h=Message-Id:Date:Subject:To:From:Cc:Date:From:Subject:Sender; bh=n8jZZfWYJ8fhGdjBqiwUsQzfJIv7DILOpRSvk8KNUHs=; b=OFSB68+jaYOA86JcXqnZDTmSa/DO0BmIGaDZrSAAF+zEJ6d2AF2PSR8lOmZEgPAFaD 1gduWve+J8Qq6wD56gAWIesHTuKeghscbIYs45F1VIK9QblMupVrGXaHmIux+A/OT70T pdmLEWGuCYn5meWlpdhyHupOcS9u7NN4oVALYA+kAmj99b/3AcDshiE9X9USAIM7dyf1 Vu93NhvFtIrkF0gn2zKk9OoTWqpLH8h6GU+UzdwzztkSYTcor793Qih/CJDbITwJ1pSq tOred0XTsF46UZah5hqW745KZya/vY1Dw60T4pP9w9OFKwm3enNGQtoIT9K49CKKMlPY UrlA== Authentication-Results: strato.com; dkim=none X-RZG-AUTH: ":I2IBZ0mrW/AWQXwgB4oxKM1YsW1lFUznrLvi/XReWqAAlWwZ8wlvfXmGs4jUQ0oz8ZbhHexs8fhgUyUAL4sh6WddW7pKJHLR+TAAqZF+" X-RZG-CLASS-ID: mo00 Received: from koenig-desktop.workgroup by smtp.strato.de (RZmta 47.37.6 AUTH) with ESMTPSA id j48e79y0GIH70Qg (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate) for ; Sun, 16 Jan 2022 19:17:07 +0100 (CET) From: Oneric To: ffmpeg-devel@ffmpeg.org Date: Sun, 16 Jan 2022 19:16:54 +0100 Message-Id: <20220116181655.6407-1-oneric@oneric.de> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/2] avcodec/{ass, webvttdec}: fix handling of backslashes X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Backslashes cannot be escaped by backslashes in any ASS renderer, but unless followed by a few specific characters it is just printed as a regular character. Insert a word-joiner character after a backslash to break up the active sequences without changing the visual output. Also the existing \{ and \} escapes are specific to libass only. --- The patch assumes UTF-8 encoding in ff_ass_bprint_text_event (WebVTT requires UTF-8 per sepc). If we cannot assume a particular encoding, please advise how to best insert a word-joiner character in the correct encoding. --- libavcodec/ass.c | 5 ++++- libavcodec/webvttdec.c | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/libavcodec/ass.c b/libavcodec/ass.c index 725e4d42ba..461e110ca4 100644 --- a/libavcodec/ass.c +++ b/libavcodec/ass.c @@ -157,8 +157,11 @@ 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); + } else if (!keep_ass_markup && *p == '\\') { + // append word-joiner U+2060 as UTF-8 to break up sequences like \N + av_bprintf(buf, "\\\xe2\x81\xa0"); /* some packets might end abruptly (no \0 at the end, like for example * in some cases of demuxing from a classic video container), some diff --git a/libavcodec/webvttdec.c b/libavcodec/webvttdec.c index 0093f328fa..8cb739697a 100644 --- a/libavcodec/webvttdec.c +++ b/libavcodec/webvttdec.c @@ -37,7 +37,7 @@ static const struct { {"", "{\\i1}"}, {"", "{\\i0}"}, {"", "{\\b1}"}, {"", "{\\b0}"}, {"", "{\\u1}"}, {"", "{\\u0}"}, - {"{", "\\{"}, {"}", "\\}"}, // escape to avoid ASS markup conflicts + {"{", "\\{"}, {"}", "\\}"}, {"\\", "\\\xe2\x81\xa0"}, // escape to avoid ASS markup conflicts {">", ">"}, {"<", "<"}, {"‎", ""}, {"‏", ""}, // FIXME: properly honor bidi marks {"&", "&"}, {" ", "\\h"}, -- 2.30.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".