mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-02-28 04:36:24 +00:00
(fix) fallback to utf-8/latin1 in rare decoding error cases - this is ugly
This commit is contained in:
@@ -872,6 +872,19 @@ static NSData* _sanitizeContent(NSData *theData)
|
||||
usingEncodingNamed: [[bodyInfo objectForKey:@"parameterList"]
|
||||
objectForKey: @"charset"]];
|
||||
|
||||
// In some rare cases (like #3276), we can get utterly broken email messages where
|
||||
// HTML parts are wrongly encoded. We try to fall back to UTF-8 if that happens and
|
||||
// if it still happens, we fall back to ISO-Latin-1.
|
||||
if (!s)
|
||||
{
|
||||
s = [[NSString alloc] initWithData: preparsedContent encoding: NSUTF8StringEncoding];
|
||||
|
||||
if (!s)
|
||||
s = [[NSString alloc] initWithData: preparsedContent encoding: NSISOLatin1StringEncoding];
|
||||
|
||||
AUTORELEASE(s);
|
||||
}
|
||||
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
preparsedContent = [s dataUsingEncoding: NSUTF16BigEndianStringEncoding];
|
||||
enc = XML_CHAR_ENCODING_UTF16BE;
|
||||
|
||||
Reference in New Issue
Block a user