Skip to content

Commit 508df69

Browse files
committed
Do not use unicode format for JSON escapes.
Text is commonly already UTF8-encoded, but could be arbitrary binary data so the application needs to handle this.
1 parent d736dad commit 508df69

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Sming/Core/Data/Format/Json.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,16 @@ namespace Format
1818
Json json;
1919

2020
/*
21-
* Check for invalid characters and replace them - can break browser
22-
* operation otherwise.
21+
* JSON requires control characters, quotes and reverse solidus (backslash) to be escaped.
2322
*
24-
* This can occur if filenames become corrupted, so here we just
25-
* substitute an underscore _ for anything which fails to match UTF8.
23+
* All other codepoints from 0x20 to 0xff are left unchanged.
24+
* This is typically UTF8 but it could be binary or some other application-defined encoding.
25+
*
26+
* Therefore no validation is performed on the data.
2627
*/
2728
void Json::escape(String& value) const
2829
{
29-
escapeControls(value, Option::unicode | Option::doublequote | Option::backslash);
30+
escapeControls(value, Option::doublequote | Option::backslash);
3031
}
3132

3233
void Json::quote(String& value) const

0 commit comments

Comments
 (0)