mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-03-05 07:06:25 +00:00
fix(mail): Use text/plain fallback if an error occured while parsing html message
This commit is contained in:
@@ -750,6 +750,7 @@ _xmlCharsetForCharset (NSString *charset)
|
||||
if ((self = [super init]))
|
||||
{
|
||||
handler = nil;
|
||||
ex = nil;
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -758,6 +759,9 @@ _xmlCharsetForCharset (NSString *charset)
|
||||
- (void) dealloc
|
||||
{
|
||||
[handler release];
|
||||
if (ex) {
|
||||
[ex release];
|
||||
}
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
@@ -782,6 +786,8 @@ _xmlCharsetForCharset (NSString *charset)
|
||||
|
||||
xmlCharEncoding enc;
|
||||
|
||||
[self cleanException];
|
||||
|
||||
if ([[self decodedFlatContent] isKindOfClass: [NGMimeBodyPart class]])
|
||||
preparsedContent = [[[self decodedFlatContent] body] sanitizedContentUsingVoidTags: VoidTags];
|
||||
else
|
||||
@@ -852,9 +858,37 @@ _xmlCharsetForCharset (NSString *charset)
|
||||
[handler setContentEncoding: enc];
|
||||
|
||||
[parser setContentHandler: handler];
|
||||
[parser setErrorHandler: self];
|
||||
[parser parseFromSource: preparsedContent];
|
||||
}
|
||||
|
||||
- (void)cleanException
|
||||
{
|
||||
ex = nil;
|
||||
}
|
||||
|
||||
- (void)warning:(SaxParseException *)_exception
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
- (void)error:(SaxParseException *)_exception
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
- (void)fatalError:(SaxParseException *)_exception
|
||||
{
|
||||
ex = [NSException exceptionWithName:[_exception name] reason: [_exception reason] userInfo: [_exception userInfo]];
|
||||
[ex retain];
|
||||
}
|
||||
|
||||
- (NSException *)getException
|
||||
{
|
||||
return ex;
|
||||
}
|
||||
|
||||
|
||||
- (NSString *) cssContent
|
||||
{
|
||||
NSString *cssContent, *css;
|
||||
@@ -890,6 +924,7 @@ _xmlCharsetForCharset (NSString *charset)
|
||||
if ((self = [super init]))
|
||||
{
|
||||
handler = nil;
|
||||
ex = nil;
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -898,6 +933,9 @@ _xmlCharsetForCharset (NSString *charset)
|
||||
- (void) dealloc
|
||||
{
|
||||
[handler release];
|
||||
if (ex) {
|
||||
[ex release];
|
||||
}
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
@@ -921,6 +959,8 @@ _xmlCharsetForCharset (NSString *charset)
|
||||
NSString *encoding;
|
||||
xmlCharEncoding enc;
|
||||
|
||||
[self cleanException];
|
||||
|
||||
parser = [[SaxXMLReaderFactory standardXMLReaderFactory]
|
||||
createXMLReaderForMimeType: @"text/html"];
|
||||
|
||||
@@ -966,9 +1006,36 @@ _xmlCharsetForCharset (NSString *charset)
|
||||
|
||||
[handler setContentEncoding: enc];
|
||||
[parser setContentHandler: handler];
|
||||
[parser setErrorHandler: self];
|
||||
[parser parseFromSource: preparsedContent];
|
||||
}
|
||||
|
||||
- (void)cleanException
|
||||
{
|
||||
ex = nil;
|
||||
}
|
||||
|
||||
- (void)warning:(SaxParseException *)_exception
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
- (void)error:(SaxParseException *)_exception
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
- (void)fatalError:(SaxParseException *)_exception
|
||||
{
|
||||
ex = [NSException exceptionWithName:[_exception name] reason: [_exception reason] userInfo: [_exception userInfo]];
|
||||
[ex retain];
|
||||
}
|
||||
|
||||
- (NSException *)getException
|
||||
{
|
||||
return ex;
|
||||
}
|
||||
|
||||
- (NSString *) filename
|
||||
{
|
||||
return [[self clientObject] filename];
|
||||
|
||||
Reference in New Issue
Block a user