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

* fix breaking typo in json.zig

* add tests
This commit is contained in:
Auguste Rame 2020-04-27 12:22:43 -04:00 committed by GitHub
parent a17eb15e11
commit 0df82889cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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" {