From a0f950a57be97a09ff1ea8a1339232379d37574c Mon Sep 17 00:00:00 2001 From: Sascha Volkenandt Date: Thu, 18 Jan 2007 20:20:20 +0000 Subject: - added function StringEscapeAndBreak, which *first* html-escapes a string and *second* replaces \n by
- using StringEscapeAndBreak for description in whats_on --- pages/whats_on.ecpp | 2 +- tools.cpp | 12 +++++++++++- tools.h | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/pages/whats_on.ecpp b/pages/whats_on.ecpp index 01010a3..be36f96 100644 --- a/pages/whats_on.ecpp +++ b/pages/whats_on.ecpp @@ -79,7 +79,7 @@ if (type == "now") {
<$ title $>
<$ short_description $>
- <$ description $> + <{ reply.out() << StringEscapeAndBreak( description ); }>
diff --git a/tools.cpp b/tools.cpp index 2382d8f..9445c93 100644 --- a/tools.cpp +++ b/tools.cpp @@ -1,13 +1,15 @@ #include +#include +#include #include #include -#include #include "exception.h" #include "live.h" #include "setup.h" #include "tools.h" using namespace std; +using namespace tnt; istream& operator>>( istream& is, tChannelID& ret ) { @@ -93,4 +95,12 @@ string StringWordTruncate(const string& input, size_t maxLen, bool& truncated) return result.substr(0, pos); } +string StringEscapeAndBreak( string const& input ) +{ + stringstream plainBuilder; + HtmlEscOstream builder( plainBuilder ); + builder << input; + return StringReplace( plainBuilder.str(), "\n", "
" ); +} + } // namespace vdrlive diff --git a/tools.h b/tools.h index a269d22..589767c 100644 --- a/tools.h +++ b/tools.h @@ -27,6 +27,7 @@ std::vector< std::string > StringSplit( std::string const& text, char delimiter int StringToInt( std::string const& string, int base = 10 ); std::string StringRepeat(int times, const std::string& input); std::string StringWordTruncate(const std::string& input, size_t maxLen, bool& truncated); +std::string StringEscapeAndBreak( std::string const& input ); struct bad_lexical_cast: std::runtime_error { -- cgit v1.2.3