authorgravatar for Auguste.rame@gmail.comAuguste Rame <Auguste.rame@gmail.com> 2020-04-27 12:22:43-04:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2020-04-27 12:22:43-04:00
log0df82889cf01757f2c19f841a5e3446a5ba70eac
tree7fd4da55d660eede37e4f7441ca18f4e133bcb9e
parenta17eb15e115dd104f4b0bf2b1db04c06432da324
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

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

* fix breaking typo in json.zig * add tests

1 files changed, 3 insertions(+), 1 deletions(-)

lib/std/json.zig+3-1
...@@ -2520,7 +2520,7 @@ pub fn stringify(...@@ -2520,7 +2520,7 @@ pub fn stringify(
2520 if (options.string.String.escape_solidus) {2520 if (options.string.String.escape_solidus) {
2521 try out_stream.writeAll("\\/");2521 try out_stream.writeAll("\\/");
2522 } else {2522 } else {
2523 try out_stream.writeByte('\\');2523 try out_stream.writeByte('/');
2524 }2524 }
2525 },2525 },
2526 // control characters with short escapes2526 // control characters with short escapes
...@@ -2670,6 +2670,8 @@ test "stringify string" {...@@ -2670,6 +2670,8 @@ test "stringify string" {
2670 try teststringify("\"with unicode\\ud800\\udc00\"", "with unicode\u{10000}", StringifyOptions{ .string = .{ .String = .{ .escape_unicode = true } } });2670 try teststringify("\"with unicode\\ud800\\udc00\"", "with unicode\u{10000}", StringifyOptions{ .string = .{ .String = .{ .escape_unicode = true } } });
2671 try teststringify("\"with unicode\u{10FFFF}\"", "with unicode\u{10FFFF}", StringifyOptions{});2671 try teststringify("\"with unicode\u{10FFFF}\"", "with unicode\u{10FFFF}", StringifyOptions{});
2672 try teststringify("\"with unicode\\udbff\\udfff\"", "with unicode\u{10FFFF}", StringifyOptions{ .string = .{ .String = .{ .escape_unicode = true } } });2672 try teststringify("\"with unicode\\udbff\\udfff\"", "with unicode\u{10FFFF}", StringifyOptions{ .string = .{ .String = .{ .escape_unicode = true } } });
2673 try teststringify("\"/\"", "/", StringifyOptions{});
2674 try teststringify("\"\\/\"", "/", StringifyOptions{ .string = .{ .String = .{ .escape_solidus = true } } });
2673}2675}
26742676
2675test "stringify tagged unions" {2677test "stringify tagged unions" {