Skip to content

Commit

Permalink
Fixed string escape crash
Browse files Browse the repository at this point in the history
  • Loading branch information
BrettRToomey committed Dec 3, 2017
1 parent 9a983c1 commit 497cd6f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Sources/Core/Parser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1283,7 +1283,6 @@ extension Parser {

func unquote(_ s: String) -> String {
var s = s

s = String(s.dropFirst().dropLast())

var index = s.startIndex
Expand All @@ -1292,7 +1291,9 @@ extension Parser {
index = s.index(after: index)
continue
}

s.remove(at: index)

var char: Character
switch s[index] {
case "a": char = "\u{0007}" // alert or bell
Expand All @@ -1302,7 +1303,8 @@ extension Parser {
case "r": char = "\u{000d}" // carriage return
case "t": char = "\u{0009}" // horizontal tab
case "v": char = "\u{000b}" // vertical tab
case "\\": char = "\u{005c}" // backslash
case "\\":
char = "\u{005c}" // backslash
case "\"": char = "\u{0022}" // double quote
default:
let startIndex = index
Expand Down Expand Up @@ -1336,6 +1338,7 @@ extension Parser {
continue
}
s.replaceSubrange(index ..< s.index(after: index), with: [char])
index = s.index(after: index)
}

return s
Expand Down

0 comments on commit 497cd6f

Please sign in to comment.