Bug 22628 – std.json.parseJSON's exception msg may be invalid UTF-8

Status
NEW
Severity
normal
Priority
P3
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2021-12-24T20:44:22Z
Last change time
2024-12-01T16:39:46Z
Assigned to
No Owner
Creator
kdevel
Moved to GitHub: phobos#9835 →

Comments

Comment #0 by kdevel — 2021-12-24T20:44:22Z
---json_unexpected_character.d import std.stdio; import std.json; import std.utf; void main () { auto json = "\u00fc"c; writefln ("input: <%s>", json); try parseJSON (json, JSONOptions.strictParsing); catch (Exception e) { writeln (e.msg); validate (e.msg); } } --- output (on a console in latin1 mode): input: <ÃŒ> Unexpected character 'Ã'. (Line 1:1) std.utf.UTFException@.../linux/bin64/../../src/phobos/std/utf.d(1547): Invalid UTF-8 sequence (at index 1) ---------------- .../../../src/phobos/std/utf.d:1637 pure dchar std.utf.decodeImpl!(true, 0, const(char)[]).decodeImpl(const(char)[], ref ulong) [0x499975] .../linux/bin64/../../src/phobos/std/utf.d:1186 pure @trusted dchar std.utf.decode!(0, const(immutable(char)[])).decode(ref const(immutable(char)[]), ref ulong) [0x4b8b1a] .../linux/bin64/../../src/phobos/std/utf.d:2937 pure @safe void std.utf.validate!(immutable(char)[]).validate(in immutable(char)[]) [0x4b8a32] ./json_unexpected_character.d:12 _Dmain [0x495cd2] expected: input: <ÃŒ> Unexpected character 'ÃŒ'. (Line 1:1)
Comment #1 by robert.schadek — 2024-12-01T16:39:46Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/9835 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB