diff --git a/Sources/TOMLDecoder/Parsing/Parser.swift b/Sources/TOMLDecoder/Parsing/Parser.swift index 730006c..c0e393b 100644 --- a/Sources/TOMLDecoder/Parsing/Parser.swift +++ b/Sources/TOMLDecoder/Parsing/Parser.swift @@ -1100,8 +1100,6 @@ extension Token { var index = text.lowerBound var endIndex = text.upperBound - assert(quoteChar == CodeUnits.doubleQuote || quoteChar == CodeUnits.singleQuote) - if endIndex - index >= 3 && bytes[index] == CodeUnits.doubleQuote && bytes[index + 1] == CodeUnits.doubleQuote && bytes[index + 2] == CodeUnits.doubleQuote || endIndex - index >= 3 && bytes[index] == CodeUnits.singleQuote && bytes[index + 1] == CodeUnits.singleQuote && bytes[index + 2] == CodeUnits.singleQuote { @@ -1117,7 +1115,7 @@ extension Token { } else { index = index + 1 endIndex = endIndex - 1 - guard bytes[endIndex] == quoteChar else { + guard endIndex >= 0, bytes[endIndex] == quoteChar else { throw TOMLError(.invalidString(context: context, lineNumber: lineNumber, reason: "missing closing quote")) } }