projects
/
dcpomatic.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
96fdcb3
)
Extract method to escape text.
author
Carl Hetherington
<cth@carlh.net>
Wed, 1 Jun 2022 10:23:21 +0000
(12:23 +0200)
committer
Carl Hetherington
<cth@carlh.net>
Tue, 7 Jun 2022 15:01:06 +0000
(17:01 +0200)
src/lib/text_decoder.cc
patch
|
blob
|
history
diff --git
a/src/lib/text_decoder.cc
b/src/lib/text_decoder.cc
index 88cf4bc56e492da0aefbf320fdbe21fc0220bba6..c6563a260fe238656a2c65889c13f8cdb06d1298 100644
(file)
--- a/
src/lib/text_decoder.cc
+++ b/
src/lib/text_decoder.cc
@@
-67,18
+67,25
@@
TextDecoder::emit_bitmap_start (ContentBitmapText const& bitmap)
}
}
+static
+string
+escape_text (string text)
+{
+ /* We must escape some things, otherwise they might confuse our subtitle
+ renderer (which uses entities and some HTML-esque markup to do bold/italic etc.)
+ */
+ boost::algorithm::replace_all(text, "&", "&");
+ boost::algorithm::replace_all(text, "<", "<");
+ boost::algorithm::replace_all(text, ">", ">");
+ return text;
+}
+
+
void
TextDecoder::emit_plain_start (ContentTime from, vector<dcp::SubtitleString> subtitles)
{
for (auto& subtitle: subtitles) {
void
TextDecoder::emit_plain_start (ContentTime from, vector<dcp::SubtitleString> subtitles)
{
for (auto& subtitle: subtitles) {
- /* We must escape some things, otherwise they might confuse our subtitle
- renderer (which uses entities and some HTML-esque markup to do bold/italic etc.)
- */
- string text = subtitle.text();
- boost::algorithm::replace_all(text, "&", "&");
- boost::algorithm::replace_all(text, "<", "<");
- boost::algorithm::replace_all(text, ">", ">");
- subtitle.set_text (text);
+ subtitle.set_text(escape_text(subtitle.text()));
/* Set any forced appearance */
if (content()->colour()) {
/* Set any forced appearance */
if (content()->colour()) {