From 502b59bc08c8eb167dc08c337b6605a0f2870538 Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Sat, 23 Dec 2017 09:02:32 -0500 Subject: [PATCH] (feat) handling of encypted HTML parts --- UI/MailPartViewers/UIxMailPartHTMLViewer.m | 32 +++++++++++++++------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/UI/MailPartViewers/UIxMailPartHTMLViewer.m b/UI/MailPartViewers/UIxMailPartHTMLViewer.m index c173ca9ef..1601894a7 100644 --- a/UI/MailPartViewers/UIxMailPartHTMLViewer.m +++ b/UI/MailPartViewers/UIxMailPartHTMLViewer.m @@ -1,6 +1,6 @@ /* UIxMailPartHTMLViewer.m - this file is part of SOGo * - * Copyright (C) 2007-2013 Inverse inc. + * Copyright (C) 2007-2017 Inverse inc. * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -25,10 +25,14 @@ #import #import #import +#import +#import #include #import +#import +#import #import #import @@ -718,14 +722,15 @@ _xmlCharsetForCharset (NSString *charset) { NSObject *parser; NSData *preparsedContent; - SOGoMailObject *mail; NSString *s; xmlCharEncoding enc; - mail = [self clientObject]; + if ([[self decodedFlatContent] isKindOfClass: [NGMimeBodyPart class]]) + preparsedContent = [[[self decodedFlatContent] body] sanitizedContentUsingVoidTags: VoidTags]; + else + preparsedContent = [[self decodedFlatContent] sanitizedContentUsingVoidTags: VoidTags]; - preparsedContent = [[super decodedFlatContent] sanitizedContentUsingVoidTags: VoidTags]; parser = [[SaxXMLReaderFactory standardXMLReaderFactory] createXMLReaderForMimeType: @"text/html"]; @@ -841,18 +846,25 @@ _xmlCharsetForCharset (NSString *charset) { NSObject *parser; NSData *preparsedContent; - SOGoMailObject *mail; SOGoMailBodyPart *part; NSString *encoding; xmlCharEncoding enc; - part = [self clientObject]; - mail = [part mailObject]; - - preparsedContent = [[part fetchBLOB] sanitizedContentUsingVoidTags: VoidTags]; parser = [[SaxXMLReaderFactory standardXMLReaderFactory] createXMLReaderForMimeType: @"text/html"]; - encoding = [[part partInfo] valueForKey: @"encoding"]; + + if ([[self decodedFlatContent] isKindOfClass: [NGMimeBodyPart class]]) + { + preparsedContent = [[[self decodedFlatContent] body] sanitizedContentUsingVoidTags: VoidTags]; + encoding = [[[self decodedFlatContent] contentType] valueOfParameter: @"charset"]; + } + else + { + part = [self clientObject]; + preparsedContent = [[part fetchBLOB] sanitizedContentUsingVoidTags: VoidTags]; + encoding = [[part partInfo] valueForKey: @"encoding"]; + } + if (![encoding length]) encoding = @"us-ascii";