Commit d10544b7 authored by Sandro Knauß's avatar Sandro Knauß 🐝
Browse files

Add Fix for Kontact creates broken pgp signed mails.

Wenn we construct a signed message, we want to make sure, that the mail
itself is parsable for other MUAs, so we fix CE7Bit messages that contain
quoted-printable-like character when signing (1efea1c00df92e43d0ff66073851f48471d9d76b)
But this behaviour we only should do if it is text we sign and not a
mimestructure (multipart/mixed) already.
parent 292d86c4
......@@ -157,7 +157,55 @@ void SignJobTest::testRecommentationRFC3156()
ComposerTestUtil::verify(true, false, result, data.toUtf8(),
Kleo::OpenPGPMIMEFormat, cte);
}
void SignJobTest::testMixedContent()
{
std::vector< GpgME::Key > keys = MessageComposer::Test::getKeys();
QString data = QString::fromUtf8("=2D Magic foo\nFrom test\n\n-- quaak\nOhno");
MessageComposer::Composer *composer = new MessageComposer::Composer;
MessageComposer::SignJob* sJob = new MessageComposer::SignJob(composer);
QVERIFY(composer);
QVERIFY(sJob);
KMime::Content* content = new KMime::Content;
content->contentType()->setMimeType(QByteArray("multipart/mixed"));
content->contentType()->setBoundary( KMime::multiPartBoundary() );
KMime::Content* subcontent = new KMime::Content;
subcontent->contentType()->setMimeType(QByteArray("text/plain"));
subcontent->setBody( data.toUtf8() );
KMime::Content* attachment = new KMime::Content;
attachment->contentType()->setMimeType(QByteArray("text/plain"));
QByteArray attachmentData("an attachment");
attachment->setBody(attachmentData);
content->addContent(subcontent);
content->addContent(attachment);
content->assemble();
sJob->setContent(content);
sJob->setCryptoMessageFormat(Kleo::OpenPGPMIMEFormat);
sJob->setSigningKeys(keys);
VERIFYEXEC(sJob);
KMime::Content *result = sJob->content();
result->assemble();
qDebug() << result->encodedContent();
KMime::Content* firstChild = MessageCore::NodeHelper::firstChild(result);
QCOMPARE(result->contents().count(), 2);
QCOMPARE(firstChild->contents().count(), 2);
QCOMPARE(firstChild->body(), QByteArray());
QCOMPARE(firstChild->contentType()->mimeType(), QByteArray("multipart/mixed"));
QCOMPARE(firstChild->contents()[0]->body(), data.toUtf8());
QCOMPARE(firstChild->contents()[1]->body(), attachmentData);
ComposerTestUtil::verify(true, false, result, data.toUtf8(),
Kleo::OpenPGPMIMEFormat, KMime::Headers::CE7Bit);
}
void SignJobTest::checkSignJob(MessageComposer::SignJob *sJob)
......
......@@ -43,6 +43,7 @@ private Q_SLOTS:
void testContentChained();
void testHeaders();
void testRecommentationRFC3156();
void testMixedContent();
private:
void checkSignJob(MessageComposer::SignJob *sJob);
......
......@@ -168,8 +168,9 @@ void SignJob::process()
// Note: If any line begins with the string "From ", it is strongly
// suggested that either the Quoted-Printable or Base64 MIME encoding
// be applied.
if (d->content->contentTransferEncoding()->encoding() == KMime::Headers::CEquPr ||
d->content->contentTransferEncoding()->encoding() == KMime::Headers::CE7Bit) {
const auto encoding = d->content->contentTransferEncoding()->encoding();
if ((encoding == KMime::Headers::CEquPr || encoding == KMime::Headers::CE7Bit)
&& !d->content->contentType(false)) {
QByteArray body = d->content->encodedBody();
bool changed = false;
QList<QByteArray> search;
......
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