[Issue 22628] New: std.json.parseJSON's exception msg may be invalid UTF-8
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Dec 24 20:44:22 UTC 2021
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 at puremagic.com
Reporter: kdevel at 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 at .../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)
--
More information about the Digitalmars-d-bugs
mailing list