(fix) handle more broken mails (fixes #4513)

pull/252/head
Ludovic Marcotte 2019-06-13 13:54:16 -04:00
parent 991fac0b94
commit 4fc515b229
1 changed files with 7 additions and 0 deletions

View File

@ -846,6 +846,13 @@ _xmlCharsetForCharset (NSString *charset)
if (enc == XML_CHAR_ENCODING_UTF8)
{
s = [[NSString alloc] initWithData: preparsedContent encoding: NSUTF8StringEncoding];
// Again, In some rare cases (like #4513), 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: NSISOLatin1StringEncoding];
preparsedContent = [[s safeString] dataUsingEncoding: NSUTF8StringEncoding];
RELEASE(s);
}