summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2016-08-20 01:07:35 +0100
committerCarl Hetherington <cth@carlh.net>2016-08-20 01:07:35 +0100
commit2dd34ab7469a8a01de368b7a204ad0e8f2d5aefd (patch)
treeb88081b061c3b97daeb1c5bc87cdbaefda7fd6a0 /src
parent8f698532b42f300029adf94c62c0f509489318c3 (diff)
Handle subtitles which contain Pango markup.
Diffstat (limited to 'src')
-rw-r--r--src/lib/subtitle_decoder.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/lib/subtitle_decoder.cc b/src/lib/subtitle_decoder.cc
index ba6fe4600..bc4a75ca8 100644
--- a/src/lib/subtitle_decoder.cc
+++ b/src/lib/subtitle_decoder.cc
@@ -24,6 +24,7 @@
#include <sub/subtitle.h>
#include <boost/shared_ptr.hpp>
#include <boost/foreach.hpp>
+#include <boost/algorithm/string.hpp>
#include <iostream>
using std::list;
@@ -64,6 +65,16 @@ SubtitleDecoder::give_image (ContentTimePeriod period, shared_ptr<Image> image,
void
SubtitleDecoder::give_text (ContentTimePeriod period, list<dcp::SubtitleString> s)
{
+ /* We must escape < and > in strings, otherwise they might confuse our subtitle
+ renderer (which uses some HTML-esque markup to do bold/italic etc.)
+ */
+ BOOST_FOREACH (dcp::SubtitleString& i, s) {
+ string t = i.text ();
+ boost::algorithm::replace_all (t, "<", "&lt;");
+ boost::algorithm::replace_all (t, ">", "&gt;");
+ i.set_text (t);
+ }
+
_decoded_text.push_back (ContentTextSubtitle (period, s));
}