Extend xml escape with enter and tabulator

This commit is contained in:
Filip Sykala 2021-09-22 13:54:00 +02:00
parent 7a3b220f0a
commit 4c416bc747

View File

@ -911,7 +911,7 @@ std::string xml_escape(std::string text, bool is_marked/* = false*/)
std::string::size_type pos = 0; std::string::size_type pos = 0;
for (;;) for (;;)
{ {
pos = text.find_first_of("\"\'&<>", pos); pos = text.find_first_of("\"\'&<>\n\t", pos);
if (pos == std::string::npos) if (pos == std::string::npos)
break; break;
@ -923,6 +923,8 @@ std::string xml_escape(std::string text, bool is_marked/* = false*/)
case '&': replacement = "&amp;"; break; case '&': replacement = "&amp;"; break;
case '<': replacement = is_marked ? "<" :"&lt;"; break; case '<': replacement = is_marked ? "<" :"&lt;"; break;
case '>': replacement = is_marked ? ">" : "&gt;"; break; case '>': replacement = is_marked ? ">" : "&gt;"; break;
case '\n': replacement = "&#x000A;"; break;
case '\t': replacement = "&#x0009;"; break;
default: break; default: break;
} }