Namedsearches - Escape for XML special chars

... in the escape &, ' and " as special XML chars where missing
....... causing that a rule for cLucene with "&&" could be stored, but
got lost on reading
This commit is contained in:
Joern
2014-11-09 15:06:46 +01:00
parent b77ab9c5ab
commit 92cfbbd02f

View File

@@ -22,7 +22,7 @@
#include "Athlete.h"
#include "GcSideBarItem.h" // for iconFromPNG
// Escape special characters (JSON compliance)
// Escape special characters (JSON compliance & XML)
static QString protect(const QString string)
{
QString s = string;
@@ -36,9 +36,15 @@ static QString protect(const QString string)
s.replace("/", "\\/"); // solidus
s.replace(">", ">"); // angle
s.replace("<", "&lt;"); // angle
s.replace("&", "&amp;"); // ampersand
s.replace("'", "&apos;"); // apostrophe
s.replace('"', "&quot;"); // quote
return s;
}
// Un-Escape special characters (JSON compliance)
static QString unprotect(const QString string)
{
@@ -58,6 +64,10 @@ static QString unprotect(const QString string)
s.replace("\\\\", "\\"); // backslash
s.replace("&gt;", ">"); // angle
s.replace("&lt;", "<"); // angle
s.replace("&amp;", "&"); // ampersand
s.replace("&apos;", "'"); // apostrophe
s.replace("&quot;", "\""); // quote
return s;
}