Skip to content

Commit

Permalink
Merge branch 'master' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
mdmathias authored Jan 19, 2017
2 parents c0548b6 + 7e85f22 commit a1ecff0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions Sources/JSONParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ public struct JSONParser {
switch input[loc] {
case Literal.BACKSLASH:
loc = (loc + 1)
guard loc < input.count else { continue }
switch input[loc] {
case Literal.DOUBLE_QUOTE: stringDecodingBuffer.append(Literal.DOUBLE_QUOTE)
case Literal.BACKSLASH: stringDecodingBuffer.append(Literal.BACKSLASH)
Expand Down
11 changes: 11 additions & 0 deletions Tests/FreddyTests/JSONParserTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -482,4 +482,15 @@ class JSONParserTests: XCTestCase {
}
}
}

func testThatParserRejectsStringEndingInBackslash() {
let invalidJSONString = "[\"\\"
do {
_ = try JSONParser.parse(invalidJSONString)
} catch JSONParser.Error.endOfStreamUnexpected {
// do nothing - this is the expected error
} catch {
XCTFail("Unexpected error: \(error)")
}
}
}

0 comments on commit a1ecff0

Please sign in to comment.