Repalced regex in URI::remove_newlines() with search & replace.

This commit is contained in:
tastytea 2019-05-23 13:41:47 +02:00
parent 92f87fb85b
commit c7165f7ffe
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
2 changed files with 10 additions and 3 deletions

View File

@ -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;
}

View File

@ -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