diff --git a/mimetreeparser/autotests/data/inlinepgpencrypted-error.mbox b/mimetreeparser/autotests/data/inlinepgpencrypted-error.mbox new file mode 100644 --- /dev/null +++ b/mimetreeparser/autotests/data/inlinepgpencrypted-error.mbox @@ -0,0 +1,55 @@ +From test@kolab.org Wed, 25 May 2011 23:49:40 +0100 +From: OpenPGP Test +To: test@kolab.org +Subject: inlinepgpencrypted - no seckey +Date: Wed, 25 May 2011 23:49:40 +0100 +Message-ID: <1786696.yKXrOjjflF@herrwackelpudding.localhost> +X-KMail-Transport: GMX +X-KMail-Fcc: 28 +X-KMail-Drafts: 7 +X-KMail-Templates: 9 +User-Agent: KMail/4.6 beta5 (Linux/2.6.34.7-0.7-desktop; KDE/4.6.41; x86_64; git-0269848; 2011-04-19) +MIME-Version: 1.0 +Content-Transfer-Encoding: 7Bit +Content-Type: text/plain; charset="us-ascii" + +-----BEGIN PGP MESSAGE----- +Version: GnuPG v2 + +hQIMA1U9QmLaS63yAQ/8C8o5D7wQ9LoPHrNCNelku19bwQogTIqxRJSTYzO0b0tr +Pb7Oyxkm1XabYxhg9bxFcNvvAbxcbzmnFJqkVPzCird43N5BDMtwGumiUjNNYVgy +4tD6hs+h8GsmmQ5/J5cmuUwA+Ee20ubrTMH2qkU75WcyuRAG+IFsA80eEKG5qR8y +i2WXjBiImcmjrEVtSA3L+mUHmhuWxz/46EnCelSAJMfhSG8zuTJnK6OFBSDQNkqE +NRJl0PO4DYDeJiSYeXWEB2GTvc9JXtcHm7wIwzHXHSrBlXvQWEj5B8z9GSOJwO0o +JuV29TVU4iDU8d3flfhMGZEJXUkIIwt66/0CtuJNDmIAnqc4wQO9LtXFXOI/YK7x +twidnLY04kmh1bZfQsUBhwdYqLUzr0AXqE2kRTozod4XgVBmphVt6Ytu11L1UFdb +1wKBaQG/qmhOmeMJb7eJX6I66p8LzKiqkfNlTnPQURELMbCmiRwoDCC5wnrDj8g/ +K0zvfNRFbGimbTHeQ01OncoVcRIlXK7njM6dTTqnglzwZagHn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1NPRibfdL9aMzjPfxmE91vaN29NnxQJG2w7KnI7sxXvZljOvuSI +FE9NvGs2uHjRFjO0Vncjuv/fAbdvVvkTCSyLWZLUyOegJa/0KZOU48HtwwBzVxl1 +D9joee2bmQnmxuGomRwelUVbux1GKRhfCtnNuKQNXU7NP3AnNUDAQjrQSD5C1f3e +9tPOi3wRuXnlYfBcmemKUrdYNVpWBpHh+KnJ1rW/NqwNvUtq0ucYIT5//dKaPiIf +HqizKm0MntFbIv4f29TNfw5Wp1GcTXc6Dmt/KSCjLH+IxPtdAgI5ZlrdOfVxlY1B +abIFKjN0csPfkfX7l8g6ekOYgP/NRHQQs7Zyds59Zj7Roi7+uabV8svXRREm0V34 +595ro3cEzABOAnErxErC7Lm/VUI348kdOP/3IAckmwv1qts3P2eDA6CcLYE2V+sz +7mb9UGrUzu8hBxPjbuqIYfi2XOSxGRCvSH0Rmw7XzKfSRwHpusUQjpCbRXyntVqY +Db8+PufLBENx22ipLLEDltP1P9zRuy2KpANd0sggM/HtUC3Bjta7IR9Q3qbVcPDx +3Qu241eOBdb6 +=J3lb +-----END PGP MESSAGE----- diff --git a/mimetreeparser/autotests/data/inlinepgpencrypted-error.mbox.html b/mimetreeparser/autotests/data/inlinepgpencrypted-error.mbox.html new file mode 100644 --- /dev/null +++ b/mimetreeparser/autotests/data/inlinepgpencrypted-error.mbox.html @@ -0,0 +1,24 @@ + + + + +
+ +
+ + + + + + + + + + +
Encrypted message (decryption not possible)
Reason: Crypto plug-in "OpenPGP" could not decrypt the data.
Error: Decryption failed
+
No secret key found to encrypt the message. It is encrypted for following keys:
0x553D4262DA4BADF2
0xF6E6A3D126C630E0
+
End of encrypted message
+
+
+ + diff --git a/mimetreeparser/src/viewer/objecttreeparser.cpp b/mimetreeparser/src/viewer/objecttreeparser.cpp --- a/mimetreeparser/src/viewer/objecttreeparser.cpp +++ b/mimetreeparser/src/viewer/objecttreeparser.cpp @@ -671,8 +671,7 @@ bDecryptionOk = true; decryptedData = plainText; } else { - passphraseError = decryptResult.error().isCanceled() - || decryptResult.error().code() == GPG_ERR_NO_SECKEY; + passphraseError = decryptResult.error().isCanceled() || decryptResult.error().code() == GPG_ERR_NO_SECKEY; actuallyEncrypted = decryptResult.error().code() != GPG_ERR_NO_DATA; partMetaData.errorText = QString::fromLocal8Bit(decryptResult.error().asString()); partMetaData.isEncrypted = actuallyEncrypted; @@ -684,9 +683,31 @@ if (bDecryptionOk) { decryptedData = plainText; } else if (htmlWriter() && showWarning) { - decryptedData = "
" - + errorMsg.toUtf8() - + "
"; + bool noSecKey = true; + const QString sNoSecKeyHeader = i18n("No secret key found to encrypt the message. It is encrypted for following keys:"); + QString secKeyList; + foreach (const GpgME::DecryptionResult::Recipient &recipient, decryptResult.recipients()) { + noSecKey &= (recipient.status().code() == GPG_ERR_NO_SECKEY); + + if (!secKeyList.isEmpty()) { + secKeyList += QStringLiteral("
"); + } + + secKeyList += QStringLiteral("
%4") + .arg(cryptProto->displayName(), + cryptProto->name(), + QString::fromLatin1(recipient.keyID()), + QString::fromLatin1(QByteArray("0x") + recipient.keyID()) + ); + } + + decryptedData = "
"; + if (noSecKey) { + decryptedData += QString(sNoSecKeyHeader + QStringLiteral("
") + secKeyList).toUtf8(); + } else { + decryptedData += errorMsg.toUtf8(); + } + decryptedData += "
"; if (!passphraseError) { partMetaData.errorText = i18n("Crypto plug-in \"%1\" could not decrypt the data.", cryptPlugLibName) + QLatin1String("
")