From patchwork Sat Sep 10 08:45:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodger Combs X-Patchwork-Id: 527 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.134 with SMTP id o128csp694299vsd; Sat, 10 Sep 2016 01:45:48 -0700 (PDT) X-Received: by 10.195.12.170 with SMTP id er10mr4566190wjd.116.1473497148364; Sat, 10 Sep 2016 01:45:48 -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 p184si6593230wmp.85.2016.09.10.01.45.46; Sat, 10 Sep 2016 01:45:48 -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 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 E1817689D94; Sat, 10 Sep 2016 11:45:17 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-oi0-f65.google.com (mail-oi0-f65.google.com [209.85.218.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6C3CF689C8F for ; Sat, 10 Sep 2016 11:45:11 +0300 (EEST) Received: by mail-oi0-f65.google.com with SMTP id s71so10888113oih.3 for ; Sat, 10 Sep 2016 01:45:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:in-reply-to:references; bh=ZjZqNCc4gVfUdLYOTeMDWbRg+VFEgzQAL776V5wZKuk=; b=BebIiJxArl0SxdvGDC3j6dzKb1oCM2ZPlyNEKr1SYzX4S2m1cCybjCjrFvkATDc+ZJ cLY6Wvk5yDadStMqVZUG+/H42IwA8RYVv7NS47Nj2nvpHkadsJvY3YtjI8kUQv1YwKuU bsv0tsN354Yli3rIBiB3+k8H6sZHHzOT4eor+sjlUdB+PIJCL7KXe7Uw0PGuSCJecNKr cI+tln37c/4DfBwbMuzx/c9g7lPZaAt2hoTZScZajicRku7dxr1FyvG4O4SANex4Eavr SacUBdFBpp4dU+bLupxDMAZAqsTHTiB6G4UtKef81D2/0eOfDBH+PxLRH+feLyPaaOpQ V1Rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=ZjZqNCc4gVfUdLYOTeMDWbRg+VFEgzQAL776V5wZKuk=; b=IcIzRqjmNG6yRrPazfEUeO4sLfrbVekH6NR3t2ycWMb+rBWc8JmORF8/faKy1/8HvG Dli7rAVNXXSp1qxj0/zuLqGgf7wf6Zo6OQcW+ddTvMbiHb+j//OC4crTNrEBKzjniwC5 OTZIVflD4k9JrhzZWlNvd1w2kbABSg8SuW08ONRB3qk6444ajQs0IxN0EZLjSd+Y1Tik 22bjvzQD2Ea9EFHNLKVsbWkNlh9qiL05aZDQFUTne+rbpvtjEnZBgbhMO6cRXLkVjRl+ XYdQVJnxHnYc/uqyIUiDS2VhSaB0SPFK/Tzx0t3W/iwHoE3G2Sjd6oGCXJ8dJ3y3aaMx rUaA== X-Gm-Message-State: AE9vXwN1iRYIa6eTBM2enVoNgZPmxJiiqPqDJAXFQhcnsKvGYBKL95LmP+8vqiRigD3lEA== X-Received: by 10.202.252.10 with SMTP id a10mr13134955oii.124.1473497121212; Sat, 10 Sep 2016 01:45:21 -0700 (PDT) Received: from Rodgers-MacBook-Pro.local.net (c-73-209-137-129.hsd1.il.comcast.net. [73.209.137.129]) by smtp.gmail.com with ESMTPSA id z125sm8849512itc.0.2016.09.10.01.45.20 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 10 Sep 2016 01:45:20 -0700 (PDT) From: Rodger Combs To: ffmpeg-devel@ffmpeg.org Date: Sat, 10 Sep 2016 03:45:15 -0500 Message-Id: <20160910084515.11048-3-rodger.combs@gmail.com> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20160910084515.11048-1-rodger.combs@gmail.com> References: <20160910084515.11048-1-rodger.combs@gmail.com> Subject: [FFmpeg-devel] [PATCH 3/3] 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 c84bbf4..0f51e73 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 ba567c3..08903e3 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>