From c7165f7ffee6d01a74d3be4e20fa105b057b8a5b Mon Sep 17 00:00:00 2001 From: tastytea Date: Thu, 23 May 2019 13:41:47 +0200 Subject: [PATCH] Repalced regex in URI::remove_newlines() with search & replace. --- src/uri.cpp | 10 ++++++++-- src/uri.hpp | 3 ++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/uri.cpp b/src/uri.cpp index f7fa10f..03a1d72 100644 --- a/src/uri.cpp +++ b/src/uri.cpp @@ -505,7 +505,13 @@ const string URI::archive() return ""; } -const string URI::remove_newlines(const string &text) +const string URI::remove_newlines(string text) { - return regex_replace(text, regex("\n"), " "); + size_t pos = 0; + while ((pos = text.find("\n", pos)) != std::string::npos) + { + text.replace(pos, 1, " "); + ++pos; + } + return text; } diff --git a/src/uri.hpp b/src/uri.hpp index f76b305..993e0e0 100644 --- a/src/uri.hpp +++ b/src/uri.hpp @@ -49,7 +49,8 @@ protected: //! Remove all HTML tags. If tag is not empty, remove tag and its content. const string remove_html_tags(const string &html, const string &tag = ""); const string unescape_html(const string &html); - const string remove_newlines(const string &text); + //! Replace newlines with spaces. + const string remove_newlines(string text); }; #endif // REMWHAREAD_URI_HPP