-
Notifications
You must be signed in to change notification settings - Fork 20
Fails to decode utf8 text in some cases #20
Copy link
Copy link
Open
Description
In the odd event that an attachment has content-type like this:
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
This may be an odd combination, but it is definitely out there in the wild and should be handled even if it is "non-standard"
The library tries to decode it as ".ascii" here:
| guard let decoded = raw.data(using: .ascii) else { throw Error.decodingFailed } |
Even though the content-transfer-encoding is specified as 7bit, the data is actually utf-8 and standard ascii decoding will fail.
The charset should possibly override the transfer encoding, or possibly the decoder could fall-back to trying .utf8 if the .ascii decode fails. For example:
guard let decoded = raw.data(using: .ascii) else {
raw.data(using: .utf8) else { throw Error.decodingFailed }
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels