digitalmars.D.bugs - [Issue 22628] New: std.json.parseJSON's exception msg may be invalid
- d-bugmail puremagic.com (47/47) Dec 24 2021 https://issues.dlang.org/show_bug.cgi?id=22628
https://issues.dlang.org/show_bug.cgi?id=22628 Issue ID: 22628 Summary: std.json.parseJSON's exception msg may be invalid UTF-8 Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: normal Priority: P1 Component: phobos Assignee: nobody puremagic.com Reporter: kdevel vogtner.de ---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) --
Dec 24 2021