mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 08:08:42 +00:00
JSON Strings and GC Tokens
.. fix json writing so that user metadata no longer conflicts with the tokens used by GoldenCheetah, e.g. a user entered "NM" in the workout code and that conflicted with the token used to delimit a torque value. .. all user strings are now saved with a space " " appended to the value and when read, if there is a trailing space it is removed.
This commit is contained in:
@@ -78,6 +78,9 @@ static QString protect(const QString string)
|
||||
s.replace("\f", "\\f"); // formfeed
|
||||
s.replace("/", "\\/"); // solidus
|
||||
|
||||
// add a trailing space to avoid conflicting with GC special tokens
|
||||
s += " ";
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -91,6 +94,9 @@ static QString unprotect(const char * string)
|
||||
// in quotes. Lets strip those first
|
||||
QString s = string2.mid(1,string2.length()-2);
|
||||
|
||||
// does it end with a space (to avoid token conflict) ?
|
||||
if (s.endsWith(" ")) s = s.mid(0, s.length()-1);
|
||||
|
||||
// now un-escape the control characters
|
||||
s.replace("\\t", "\t"); // tab
|
||||
s.replace("\\n", "\n"); // newline
|
||||
|
||||
Reference in New Issue
Block a user