[FFmpeg-devel] [PATCH 3/3] lavc/webvttenc: XML-escape text output
Rodger Combs
rodger.combs at gmail.com
Sat Sep 10 11:45:15 EEST 2016
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</u>
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
-<invalid_tag_unclosed>but show un-closed invalid html tags
-Show not opened tags</invalid_tag_not_opened>
-<
+<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
-<invalid_tag_uc par=5>but show un-closed invalid html tags
-<u>This text should be showed underlined without problems also: 2<3,5>1,4<6</u>
+<invalid_tag_uc par=5>but show un-closed invalid html tags
+<u>This text should be showed underlined without problems also: 2<3,5>1,4<6</u>
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.</s>
-Not opened tag showed as text.</xxxxx>
+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.
-<yyyy>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</b>
+the wrong closing tag should be showed</b>
--
2.10.0
More information about the ffmpeg-devel
mailing list