diff --git a/Sources/HummingbirdCore/Utils/HBParser.swift b/Sources/HummingbirdCore/Utils/HBParser.swift index 89ae55b9d..b09342e6d 100644 --- a/Sources/HummingbirdCore/Utils/HBParser.swift +++ b/Sources/HummingbirdCore/Utils/HBParser.swift @@ -596,13 +596,9 @@ extension Parser { func _percentDecode(_ original: ArraySlice, _ bytes: UnsafeMutableBufferPointer) throws -> Int { var newIndex = 0 var index = original.startIndex - - while index < original.endIndex { + while index < (original.endIndex - 2) { // if we have found a percent sign if original[index] == 0x25 { - guard original.endIndex - index >= 2 else { - throw DecodeError() - } let high = Self.asciiHexValues[Int(original[index + 1])] let low = Self.asciiHexValues[Int(original[index + 2])] index += 3 @@ -617,9 +613,13 @@ extension Parser { index += 1 } } + while index < original.endIndex { + bytes[newIndex] = original[index] + newIndex += 1 + index += 1 + } return newIndex } - guard self.index != self.range.endIndex else { return "" } do { if #available(macOS 11, macCatalyst 14.0, iOS 14.0, tvOS 14.0, *) {