Commit a291bd83 authored by Laurent Montel's avatar Laurent Montel 😁

Fix Bug 44880 - would like to be able to strip tags from html messages

FIXED-IN: 14.12.1
BUG: 44880
parent 44192c56
......@@ -59,6 +59,7 @@
#include "utils/iconnamecache.h"
#include "viewer/htmlquotecolorer.h"
#include "chiasmuskeyselector.h"
#include "converthtmltoplaintext.h"
// KDEPIM includes
#include <messagecore/utils/stringutil.h>
......@@ -1222,9 +1223,9 @@ bool ObjectTreeParser::processTextHtmlSubtype( KMime::Content * curNode, Process
QString bodyText;
if ( mSource->htmlMail() ) {
bodyText = bodyHTML;
} else {
}/* else {
bodyText = QLatin1String(StringUtil::convertAngleBracketsToHtml( partBody ));
}
}*/
if ( curNode->topLevel()->textContent() == curNode || attachmentStrategy()->defaultDisplay( curNode ) == AttachmentStrategy::Inline ||
showOnlyOneMimePart() )
......@@ -1257,6 +1258,10 @@ bool ObjectTreeParser::processTextHtmlSubtype( KMime::Content * curNode, Process
"<a href=\"kmail:loadExternal\">by clicking here</a>.") );
htmlWriter()->queue( QLatin1String("</div><br/><br/>") );
}
htmlWriter()->queue( QLatin1String("<div style=\"position: relative\">\n") );
// Make sure the body is relative, so that nothing is painted over above "Note: ..."
// if a malicious message uses absolute positioning. #137643
htmlWriter()->queue( bodyText );
} else {
htmlWriter()->queue( QLatin1String("<div class=\"htmlWarn\">\n") );
htmlWriter()->queue( i18n("<b>Note:</b> This is an HTML message. For "
......@@ -1266,11 +1271,15 @@ bool ObjectTreeParser::processTextHtmlSubtype( KMime::Content * curNode, Process
"HTML display for this message "
"<a href=\"kmail:showHTML\">by clicking here</a>.") );
htmlWriter()->queue( QLatin1String("</div><br/><br/>") );
htmlWriter()->queue( QLatin1String("<div style=\"position: relative\">\n") );
// Make sure the body is relative, so that nothing is painted over above "Note: ..."
// if a malicious message uses absolute positioning. #137643
ConvertHtmlToPlainText convert;
convert.setHtmlString(QString::fromUtf8(partBody));
QString result = convert.generatePlainText();
result.replace(QLatin1String("\n"), QLatin1String("<br>"));
htmlWriter()->queue( result );
}
// Make sure the body is relative, so that nothing is painted over above "Note: ..."
// if a malicious message uses absolute positioning. #137643
htmlWriter()->queue( QLatin1String("<div style=\"position: relative\">\n") );
htmlWriter()->queue( bodyText );
htmlWriter()->queue( QLatin1String("</div>\n" ));
mSource->setHtmlMode( Util::Html );
return true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment