Conversation
|
Thanks for your pull request, @CyberShadow! Bugzilla references
|
|
@wilzbach Is CircleCI broken on stable? |
Looks like it: |
aG0aep6G
left a comment
There was a problem hiding this comment.
Last commit (fix for issue 17557) looks bad. Rest looks good.
std/json.d
Outdated
| { | ||
| import std.exception : assertThrown; | ||
|
|
||
| assertThrown(parseJSON("\"a\nb\"")); |
There was a problem hiding this comment.
Could specify the type of the expected exception.
|
|
||
| // UTF decoding is unnecessary when parsing JSON. | ||
| static if (is(T : const(char)[])) | ||
| alias Char = char; |
There was a problem hiding this comment.
This breaks stuff:
parseJSON("\"\U0001D11E\"");
/* std.json.JSONException@std/json.d(1374): Illegal control character. (Line 1:3) */The thing is that the rest of the code assumes dchar. While char converts to dchar, it doesn't always keep the same meaning. So stuff gets misinterpreted.
In this specific case, isControl is given a char that becomes a control character when converted to dchar. So it rings the alarm even though the encoded code point in the string is not a control character. Could also go the other way: When a control character is encoded with chars that don't look like control characters, it slips through (haven't checked if this can actually happen).
…valid and should cause an exception
Since the previous commit, it was only called from one place.
…h JSONOptions.escapeNonAsciiChars
2e900a9 to
ca788f1
Compare
Hmm, it's one thing to force decoding a D string just to avoid putting Unicode control characters in the JSON text (as that would result in non-conforming JSON)... but to force decoding JSON just so we detect and throw on Unicode control characters? |
ca788f1 to
226f8e0
Compare
|
Done. |
Said done thing (posted it on the wrong PR): OK, well, I checked the latest JSON RFC (7159) and it explicitly states that we don't care about the Unicode control characters:
so, I'm going to amend this and look into disabling auto-decoding for encoding JSON as well. |
| import std.uni : isControl; | ||
| import std.ascii : isControl; | ||
| import std.utf : encode; | ||
|
|
There was a problem hiding this comment.
I'd like to assert here that escapeNonAsciiChars is not set together with Char = char. If that could happen, we'd output a \u sequence for each char in a multibyte sequence (which would be completely wrong).
There was a problem hiding this comment.
Done. Also discovered and fixed another issue (see last commit).
68149a3 to
71875c0
Compare
Bad karma? No it's due to dlang/dmd#6935 Fix: dlang/dmd#6941 |
Please see the individual commits for details.