From 69ec676c122cf0da21ecaea1c5dbde499b88105d Mon Sep 17 00:00:00 2001 From: Daniel Duan Date: Tue, 30 Dec 2025 13:27:13 -0800 Subject: [PATCH 1/2] Report string errors properly --- Sources/TOMLDecoder/Parsing/Parser.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Sources/TOMLDecoder/Parsing/Parser.swift b/Sources/TOMLDecoder/Parsing/Parser.swift index 730006c..c13bf32 100644 --- a/Sources/TOMLDecoder/Parsing/Parser.swift +++ b/Sources/TOMLDecoder/Parsing/Parser.swift @@ -1100,7 +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 +1116,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")) } } From e6041b347edc97630aac6fc4ac9f172d9e52a001 Mon Sep 17 00:00:00 2001 From: Daniel Duan Date: Tue, 30 Dec 2025 22:09:12 -0800 Subject: [PATCH 2/2] Fix format --- Sources/TOMLDecoder/Parsing/Parser.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/Sources/TOMLDecoder/Parsing/Parser.swift b/Sources/TOMLDecoder/Parsing/Parser.swift index c13bf32..c0e393b 100644 --- a/Sources/TOMLDecoder/Parsing/Parser.swift +++ b/Sources/TOMLDecoder/Parsing/Parser.swift @@ -1100,7 +1100,6 @@ extension Token { var index = text.lowerBound var endIndex = text.upperBound - 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 {