zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 0df82889cf01757f2c19f841a5e3446a5ba70eac (tree)
parent a17eb15e115dd104f4b0bf2b1db04c06432da324
Author: Auguste Rame <Auguste.rame@gmail.com>
Date:   Mon, 27 Apr 2020 12:22:43 -0400

Fix issue with std.json incorrectly replacing forward slashes with a backslash (#5167)

* fix breaking typo in json.zig

* add tests
Diffstat:
Mlib/std/json.zig | 4+++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/std/json.zig b/lib/std/json.zig @@ -2520,7 +2520,7 @@ pub fn stringify( if (options.string.String.escape_solidus) { try out_stream.writeAll("\\/"); } else { - try out_stream.writeByte('\\'); + try out_stream.writeByte('/'); } }, // control characters with short escapes @@ -2670,6 +2670,8 @@ test "stringify string" { try teststringify("\"with unicode\\ud800\\udc00\"", "with unicode\u{10000}", StringifyOptions{ .string = .{ .String = .{ .escape_unicode = true } } }); try teststringify("\"with unicode\u{10FFFF}\"", "with unicode\u{10FFFF}", StringifyOptions{}); try teststringify("\"with unicode\\udbff\\udfff\"", "with unicode\u{10FFFF}", StringifyOptions{ .string = .{ .String = .{ .escape_unicode = true } } }); + try teststringify("\"/\"", "/", StringifyOptions{}); + try teststringify("\"\\/\"", "/", StringifyOptions{ .string = .{ .String = .{ .escape_solidus = true } } }); } test "stringify tagged unions" {