Skip to content

Commit 69ec676

Browse files
committed
Report string errors properly
1 parent 5d61c18 commit 69ec676

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

Sources/TOMLDecoder/Parsing/Parser.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,6 @@ extension Token {
11001100
var index = text.lowerBound
11011101
var endIndex = text.upperBound
11021102

1103-
assert(quoteChar == CodeUnits.doubleQuote || quoteChar == CodeUnits.singleQuote)
11041103

11051104
if endIndex - index >= 3 && bytes[index] == CodeUnits.doubleQuote && bytes[index + 1] == CodeUnits.doubleQuote && bytes[index + 2] == CodeUnits.doubleQuote ||
11061105
endIndex - index >= 3 && bytes[index] == CodeUnits.singleQuote && bytes[index + 1] == CodeUnits.singleQuote && bytes[index + 2] == CodeUnits.singleQuote
@@ -1117,7 +1116,7 @@ extension Token {
11171116
} else {
11181117
index = index + 1
11191118
endIndex = endIndex - 1
1120-
guard bytes[endIndex] == quoteChar else {
1119+
guard endIndex >= 0, bytes[endIndex] == quoteChar else {
11211120
throw TOMLError(.invalidString(context: context, lineNumber: lineNumber, reason: "missing closing quote"))
11221121
}
11231122
}

0 commit comments

Comments
 (0)