summaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorClément Bœsch <u@pkh.me>2017-07-29 21:09:54 +0200
committerClément Bœsch <u@pkh.me>2017-08-01 15:50:00 +0200
commite80037186327f97fffad75161e7d71cd9f5685f6 (patch)
tree4c2425c2b7f02d4412376b69f7d532316985ba6b /libavcodec
parent55949e3e51890de36574d8b5c27889b44108a839 (diff)
downloadffmpeg-streaming-e80037186327f97fffad75161e7d71cd9f5685f6.zip
ffmpeg-streaming-e80037186327f97fffad75161e7d71cd9f5685f6.tar.gz
lavc/htmlsubtitles: improve line breaks handling
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/htmlsubtitles.c5
-rw-r--r--libavcodec/tests/htmlsubtitles.c2
2 files changed, 5 insertions, 2 deletions
diff --git a/libavcodec/htmlsubtitles.c b/libavcodec/htmlsubtitles.c
index baed284..ae2c48b 100644
--- a/libavcodec/htmlsubtitles.c
+++ b/libavcodec/htmlsubtitles.c
@@ -165,7 +165,7 @@ int ff_htmlmarkup_to_ass(void *log_ctx, AVBPrint *dst, const char *in)
#define LIKELY_A_TAG_CHAR(x) (((x) >= '0' && (x) <= '9') || \
((x) >= 'a' && (x) <= 'z') || \
((x) >= 'A' && (x) <= 'Z') || \
- (x) == '_')
+ (x) == '_' || (x) == '/')
for (i = 0; tagname[i]; i++) {
if (!LIKELY_A_TAG_CHAR(tagname[i])) {
likely_a_tag = 0;
@@ -237,7 +237,8 @@ int ff_htmlmarkup_to_ass(void *log_ctx, AVBPrint *dst, const char *in)
} else if (tagname[0] && !tagname[1] && strchr("bisu", av_tolower(tagname[0]))) {
av_bprintf(dst, "{\\%c%d}", (char)av_tolower(tagname[0]), !tag_close);
in += skip;
- } else if (!av_strcasecmp(tagname, "br")) {
+ } else if (!av_strncasecmp(tagname, "br", 2) &&
+ (!tagname[2] || (tagname[2] == '/' && !tagname[3]))) {
av_bprintf(dst, "\\N");
in += skip;
} else if (likely_a_tag) {
diff --git a/libavcodec/tests/htmlsubtitles.c b/libavcodec/tests/htmlsubtitles.c
index d0b55a4..7c89ee9 100644
--- a/libavcodec/tests/htmlsubtitles.c
+++ b/libavcodec/tests/htmlsubtitles.c
@@ -29,6 +29,8 @@ static const char * const test_cases[] = {
"Foo <foo@bar.com>", // not a tag (not alnum)
"<b> foo <I> bar </B> bla </i>", // broken nesting
+
+ "A<br>B<BR/>C<br / >D< Br >E<brk><brk/>", // misc line breaks
};
int main(void)
OpenPOWER on IntegriCloud