mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 16:18:42 +00:00
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:
@@ -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("<", "<"); // angle
|
||||
s.replace("&", "&"); // ampersand
|
||||
s.replace("'", "'"); // apostrophe
|
||||
s.replace('"', """); // 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(">", ">"); // angle
|
||||
s.replace("<", "<"); // angle
|
||||
s.replace("&", "&"); // ampersand
|
||||
s.replace("'", "'"); // apostrophe
|
||||
s.replace(""", "\""); // quote
|
||||
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user