mirror of
https://github.com/apple/swift-http-types
synced 2026-11-22 04:30:40 +00:00
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:
1 parent
b8fbf4109e
commit
0fd14cc0fc
1 file changed
+1
-1
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user