Commit 14efb142 authored by Jan Kundrát's avatar Jan Kundrát
Browse files

WebKit: convert plaintext input with NULL bytes without silent truncation

This does *not* fix HTML input containing null bytes. I don't know if this
problem is relevant for HTML e-mails as well.

BUG: 321160
REVIEW: 111030
parent 653e0220
......@@ -32,6 +32,7 @@
#include "SimplePartWidget.h"
#include "Gui/MessageView.h" // so that the compiler knows that it's a QObject
#include "Gui/Util.h"
#include "Imap/Encoders.h"
#include "Imap/Model/ItemRoles.h"
#include "Imap/Model/MailboxTree.h"
#include "Imap/Model/Model.h"
......@@ -86,6 +87,10 @@ void SimplePartWidget::slotMarkupPlainText() {
// NOTICE "single shot", we get a recursion otherwise!
disconnect(this, SIGNAL(loadFinished(bool)), this, SLOT(slotMarkupPlainText()));
// If there's no data, don't try to "fix it up"
if (!m_partIndex.isValid() || !
static const QString defaultStyle = QString::fromUtf8(
"pre{word-wrap: break-word; white-space: pre-wrap;}"
// The following line, sadly, produces a warning "QFont::setPixelSize: Pixel size <= 0 (0)".
......@@ -152,7 +157,11 @@ void SimplePartWidget::slotMarkupPlainText() {
QString htmlHeader("<html><head><style type=\"text/css\"><!--" + textColors + fontSpecification + stylesheet + "--></style></head><body><pre>");
static QString htmlFooter("\n</pre></body></html>");
QString markup = Composer::Util::plainTextToHtml(page()->mainFrame()->toPlainText(), flowedFormat);
// We cannot rely on the QWebFrame's toPlainText because of
QString markup = Composer::Util::plainTextToHtml(
// and finally set the marked up page.
page()->mainFrame()->setHtml(htmlHeader + markup + htmlFooter);
Supports Markdown
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