summaryrefslogtreecommitdiff
path: root/src/lib/subtitle_decoder.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/subtitle_decoder.cc')
-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));
}