[FFmpeg-devel] [PATCH 5/5] lavc/webvttenc: XML-escape text output

Rodger Combs rodger.combs at gmail.com
Fri Jul 17 04:04:43 CEST 2015


---
 libavcodec/webvttenc.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/libavcodec/webvttenc.c b/libavcodec/webvttenc.c
index 9f67a2e..555e7c7 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)
-- 
2.4.1



More information about the ffmpeg-devel mailing list