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
This commit is contained in:
Guoye Zhang authored and GitHub committed 2026-06-03 19:25:45 +01:00
1 parent b8fbf4109e
commit 0fd14cc0fc
1 file changed
+1 -1
+1 -1
View File
@@ -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,