From patchwork Wed Apr 12 07:11:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodger Combs X-Patchwork-Id: 3377 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.3.129 with SMTP id 123csp138976vsd; Wed, 12 Apr 2017 00:12:20 -0700 (PDT) X-Received: by 10.28.18.21 with SMTP id 21mr1253280wms.77.1491981140020; Wed, 12 Apr 2017 00:12:20 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 130si6699756wml.115.2017.04.12.00.12.15; Wed, 12 Apr 2017 00:12:19 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1EECD6897E6; Wed, 12 Apr 2017 10:11:42 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-io0-f169.google.com (mail-io0-f169.google.com [209.85.223.169]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B6505689751 for ; Wed, 12 Apr 2017 10:11:35 +0300 (EEST) Received: by mail-io0-f169.google.com with SMTP id r16so28931466ioi.2 for ; Wed, 12 Apr 2017 00:11:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=OOzq0wTmzSvXw/1bTBwbnP9QE3OczE/P1bZuF+/Ac9o=; b=qyChXWORoLT2vHL+8HY1oT1QCdqNwvv9W+2SzkufyoSwVK4/+MTCj7qMa/R7BNU2eS Ezd7nBZdwXLqZxZBONZCOoyyfPggFhlWBus03h4uLzknmFpXEXjmdNYBGQ9m00nWe96z Covj8vBbCKlP7kFKsnR15zZc84X47mM46MBz1vuUSlhJhOBuRLa5oChW/Su1d5akS49P gySXP8bx/K3Af1GEZjCjdqrLS8s6fAKH0JEYloBAH6kjiJ0ynCNDrZZlVX3wPeh4XuBU cYOO4Tro09Kl7UNcW/yfhDMnUGHKMcMcPx4X9dVWXyTQW6F1deg/a7udzM5CQOUAeheK hAcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=OOzq0wTmzSvXw/1bTBwbnP9QE3OczE/P1bZuF+/Ac9o=; b=QVEqDuLYOaYl3zMfWkX3+1iZo09qsfFk+CRHdGZwmkH38dyTDn83IzYyV7J0EOJMOA /qCcGS4MHo1zMvMJ3AbO40+56nyyAnXKtzBPXySIf5xRUdAdbNReqHb5B7Gg5qmfvyKi fZH7NVeo7XgHaKC7m3mhGwReu1TEBKCYbg9N+kyhkskLNVMZvCDASClWRhXMm6ei1Elq DhweCuNqC5uEtG0BTjQL+xO65Nu0KA5IIttSKEdunsSPnYyBRjmTUbj7RzzKmCgqcg2T GrA8200X0qu9TcTXrTAiuAvPsRhms5HzRa5MtJI0m+4z+LOgpd0recPKg3akcVm65I35 XPkw== X-Gm-Message-State: AFeK/H2HRxvV/cUGt9NsP71cNZV+/7psLF04ow9wR5pGfSVgRAe81hWrEFHXxkqpo7augg== X-Received: by 10.107.37.12 with SMTP id l12mr57470988iol.159.1491981100090; Wed, 12 Apr 2017 00:11:40 -0700 (PDT) Received: from Rodgers-MacBook-Pro.local.net (c-73-110-121-59.hsd1.il.comcast.net. [73.110.121.59]) by smtp.gmail.com with ESMTPSA id p3sm3857213ioi.20.2017.04.12.00.11.39 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 12 Apr 2017 00:11:39 -0700 (PDT) From: Rodger Combs To: ffmpeg-devel@ffmpeg.org Date: Wed, 12 Apr 2017 02:11:26 -0500 Message-Id: <20170412071127.60511-4-rodger.combs@gmail.com> X-Mailer: git-send-email 2.11.1 In-Reply-To: <20170412071127.60511-1-rodger.combs@gmail.com> References: <20170412071127.60511-1-rodger.combs@gmail.com> Subject: [FFmpeg-devel] [PATCH 4/5] lavc/webvttenc: XML-escape text output X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" The test output was previously incorrect, so the reference is updated. --- libavcodec/webvttenc.c | 7 ++++++- tests/ref/fate/sub-webvttenc | 20 ++++++++++---------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/libavcodec/webvttenc.c b/libavcodec/webvttenc.c index c84bbf4b4e..0f51e73012 100644 --- a/libavcodec/webvttenc.c +++ b/libavcodec/webvttenc.c @@ -112,7 +112,12 @@ static void webvtt_style_apply(WebVTTContext *s, const char *style) static void webvtt_text_cb(void *priv, const char *text, int len) { WebVTTContext *s = priv; - av_bprint_append_data(&s->buffer, text, len); + char *buf = av_strndup(text, len); + if (!buf) + return; + + av_bprint_escape(&s->buffer, buf, NULL, AV_ESCAPE_MODE_XML, 0); + av_free(buf); } static void webvtt_new_line_cb(void *priv, int forced) diff --git a/tests/ref/fate/sub-webvttenc b/tests/ref/fate/sub-webvttenc index ba567c33f6..08903e3a9d 100644 --- a/tests/ref/fate/sub-webvttenc +++ b/tests/ref/fate/sub-webvttenc @@ -36,18 +36,18 @@ This line should be strikethrough should be underline 00:14.501 --> 00:17.500 -> +> It would be a good thing to hide invalid html tags that are closed and show the text in them -but show un-closed invalid html tags -Show not opened tags -< +<invalid_tag_unclosed>but show un-closed invalid html tags +Show not opened tags</invalid_tag_not_opened> +< 00:17.501 --> 00:20.500 and also hide invalid html tags with parameters that are closed and show the text in them -but show un-closed invalid html tags -This text should be showed underlined without problems also: 2<3,5>1,4<6 +<invalid_tag_uc par=5>but show un-closed invalid html tags +This text should be showed underlined without problems also: 2<3,5>1,4<6 This shouldn't be underlined 00:20.501 --> 00:21.500 @@ -164,14 +164,14 @@ should be hidden. 01:02.501 --> 01:04.500 It shouldn't be strikethrough, -not opened tag showed as text. -Not opened tag showed as text. +not opened tag showed as text.</s> +Not opened tag showed as text.</xxxxx> 01:04.501 --> 01:06.500 Three lines should be strikethrough, yes. -Not closed tags showed as text +<yyyy>Not closed tags showed as text 01:06.501 --> 01:08.500 Both line should be strikethrough but -the wrong closing tag should be showed +the wrong closing tag should be showed</b>