subassconvert: do not escape likely ASS override tags
commit7f5ac4dea082a67a3578998b53d6206d51156c71
authorwm4 <wm4@nowhere>
Fri, 26 Apr 2013 17:48:13 +0000 (26 19:48 +0200)
committerUoti Urpala <uau@mplayer2.org>
Sun, 28 Apr 2013 10:41:12 +0000 (28 13:41 +0300)
treea6797de4919508ab115af332619e7b12115efe52
parent5cb9aac3da98c92c75eb2099265d2825bd1445ef
subassconvert: do not escape likely ASS override tags

Some Windows players implement rendering of SubRip files by converting
to ASS format, but fail to escape text that could be considered ASS
markup. Unfortunately, this had led to the creation of files which mix
SubRip and ASS markup, relying on rendering being implemented this way
and on the ASS markup falling through to the ASS renderer unescaped.

Add a simple heuristic to detect whether '{' is likely to start an ASS
tag: if the string starts with '{\', and there is a closing '}',
assume it's an ASS tag and pass it through unescaped, otherwise escape
the '{' properly.

Thus tags like "{\a6}" are interpreted as ASS markup, while most
legitimate uses of '{' and '}' should work fine. We assume that nobody
uses {...} for commenting text in SubRip files. (This kind of comment
is popular and legal in ASS files, though.)
sub/subassconvert.c