Bug 17555 – [REG2.070.0] Control characters in JSON data are invalid and should cause an exception
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-06-26T07:59:00Z
Last change time
2018-01-05T13:29:28Z
Keywords
pull
Assigned to
Vladimir Panteleev
Creator
Vladimir Panteleev
Comments
Comment #0 by dlang-bugzilla — 2017-06-26T07:59:00Z
As per the JSON spec, raw control characters are not allowed in Unicode data. D correctly threw upon encountering them before 2.070.0.
Test case:
//////////////// test.d ////////////////
import std.exception;
import std.json;
void main()
{
assertThrown(parseJSON("\"a\nb\""));
}
////////////////////////////////////////
After 2.070, parseJSON returns nonsense data:
writeln(parseJSON("\"a\nb\"").str)
produces:
a\u000Ab
(i.e. the characters are "escaped" despite being decoded, not encoded).
Introduced in https://github.com/dlang/phobos/pull/3872
Comment #1 by dlang-bugzilla — 2017-06-26T10:03:44Z