Skip to content

Commit 53e6921

Browse files
authored
Merge pull request #1321 from norio-nomura/escape-solidus
2 parents 2e7ea0e + ff198c8 commit 53e6921

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

Foundation/JSONSerialization.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,8 @@ private struct JSONWriter {
403403
writer("\\\"") // U+0022 quotation mark
404404
case "\\":
405405
writer("\\\\") // U+005C reverse solidus
406-
// U+002F solidus not escaped
406+
case "/":
407+
writer("\\/") // U+002F solidus
407408
case "\u{8}":
408409
writer("\\b") // U+0008 backspace
409410
case "\u{c}":

TestFoundation/TestJSONSerialization.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,6 +1316,9 @@ extension TestJSONSerialization {
13161316

13171317
json = ["i\u{1f}"]
13181318
XCTAssertEqual(try trySerialize(json), "[\"i\\u001f\"]")
1319+
1320+
json = ["j/"]
1321+
XCTAssertEqual(try trySerialize(json), "[\"j\\/\"]")
13191322
}
13201323

13211324
/* These are a programming error and should not be done

0 commit comments

Comments
 (0)