From 0fd14cc0fcec0149dbb62ad69f7337fc2f647b95 Mon Sep 17 00:00:00 2001 From: Guoye Zhang Date: Wed, 3 Jun 2026 11:25:45 -0700 Subject: [PATCH] Check that the decoded field value string is actually ISOLatin1 (#126) The decoder assumes that the string is within the ISOLatin1 range without checking, potentially allowing invalid values to be saved in an HTTPField rdar://178437865 --- Sources/HTTPTypes/HTTPField.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/HTTPTypes/HTTPField.swift b/Sources/HTTPTypes/HTTPField.swift index 8645aa9..0a4524e 100644 --- a/Sources/HTTPTypes/HTTPField.swift +++ b/Sources/HTTPTypes/HTTPField.swift @@ -245,7 +245,7 @@ extension HTTPField: Codable { let container = try decoder.container(keyedBy: CodingKeys.self) let name = try container.decode(Name.self, forKey: .name) let value = try container.decode(String.self, forKey: .value) - guard Self.isValidValue(value) else { + guard value.unicodeScalars.allSatisfy({ $0.value <= UInt8.max }) && Self.isValidValue(value) else { throw DecodingError.dataCorruptedError( forKey: .value, in: container,