feat(mail): Add 'View raw message' mail contextual option. This option open message in a popup without HTML mail CSS content modification.

This commit is contained in:
smizrahi
2024-05-22 10:15:58 +02:00
parent 9eb8039698
commit 6ac8525bfe
11 changed files with 107 additions and 3 deletions

View File

@@ -128,9 +128,11 @@ static NSString *_sanitizeHtmlForDisplay(NSString *content)
BOOL inCSSDeclaration;
BOOL hasEmbeddedCSS;
xmlCharEncoding contentEncoding;
BOOL rawContent;
}
- (NSString *) result;
- (void) activateRawContent;
@end
@@ -161,6 +163,7 @@ static NSString *_sanitizeHtmlForDisplay(NSString *content)
ignoreTag = nil;
attachmentIds = nil;
contentEncoding = XML_CHAR_ENCODING_UTF8;
rawContent = NO;
}
return self;
@@ -174,6 +177,11 @@ static NSString *_sanitizeHtmlForDisplay(NSString *content)
[super dealloc];
}
- (void)activateRawContent
{
rawContent = YES;
}
- (void) setContentEncoding: (xmlCharEncoding) newContentEncoding
{
contentEncoding = newContentEncoding;
@@ -376,7 +384,8 @@ static NSString *_sanitizeHtmlForDisplay(NSString *content)
(*(currentChar-7) == 'p' || *(currentChar-7) == 'P') &&
(*(currentChar-8) == 'm' || *(currentChar-8) == 'M') &&
(*(currentChar-9) == 'i' || *(currentChar-9) == 'I') &&
*(currentChar-10) == '!'))
*(currentChar-10) == '!')
&& !rawContent)
{
length = (currentChar - start);
[declaration appendFormat: @"%@ !important;",
@@ -759,11 +768,17 @@ static NSString *_sanitizeHtmlForDisplay(NSString *content)
{
handler = nil;
ex = nil;
rawContent = NO;
}
return self;
}
- (void)activateRawContent
{
rawContent = YES;
}
- (void) dealloc
{
[handler release];
@@ -805,6 +820,8 @@ static NSString *_sanitizeHtmlForDisplay(NSString *content)
createXMLReaderForMimeType: @"text/html"];
handler = [_UIxHTMLMailContentHandler new];
if (rawContent)
[handler activateRawContent];
[handler setAttachmentIds: attachmentIds];
// Some broken email messages have some additionnal content outside the main HTML tags which are
@@ -920,6 +937,9 @@ static NSString *_sanitizeHtmlForDisplay(NSString *content)
if (!handler)
[self _parseContent];
if (rawContent)
return [handler result];
return _sanitizeHtmlForDisplay([handler result]);
}