Skip to content

Commit

Permalink
fix(mail): wrap HTML part with HTML tags to render all content
Browse files Browse the repository at this point in the history
  • Loading branch information
cgx committed Dec 4, 2019
1 parent e71afc9 commit 47075b4
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions UI/MailPartViewers/UIxMailPartHTMLViewer.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* UIxMailPartHTMLViewer.m - this file is part of SOGo
*
* Copyright (C) 2007-2017 Inverse inc.
* Copyright (C) 2007-2019 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
Expand Down Expand Up @@ -795,6 +795,7 @@ - (void) _parseContent
{
NSObject <SaxXMLReader> *parser;
NSData *preparsedContent;
NSMutableData *htmlContent;
NSString *s;

xmlCharEncoding enc;
Expand Down Expand Up @@ -858,10 +859,17 @@ - (void) _parseContent
RELEASE(s);
}

// Some broken email messages have some additionnal content outside the main HTML tags which are
// ignored by libxml.
// We surround the whole part with additional HTML tags to render all content.
htmlContent = [NSMutableData dataWithBytes: "<html>" length: 6];
[htmlContent appendData: preparsedContent];
[htmlContent appendBytes: "</html>" length: 7];

[handler setContentEncoding: enc];

[parser setContentHandler: handler];
[parser parseFromSource: preparsedContent];
[parser parseFromSource: htmlContent];
}

- (NSString *) cssContent
Expand Down

0 comments on commit 47075b4

Please sign in to comment.