mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-01-19 05:09:22 +08:00
Resolve #600
This commit is contained in:
parent
c6850c6c3d
commit
41df46dbed
2 changed files with 19 additions and 11 deletions
|
@ -15,6 +15,7 @@ namespace MailSo\Base\StreamWrappers;
|
||||||
* @category MailSo
|
* @category MailSo
|
||||||
* @package Base
|
* @package Base
|
||||||
* @subpackage StreamWrappers
|
* @subpackage StreamWrappers
|
||||||
|
* https://www.php.net/streamwrapper
|
||||||
*/
|
*/
|
||||||
class SubStreams
|
class SubStreams
|
||||||
{
|
{
|
||||||
|
@ -214,4 +215,4 @@ class SubStreams
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
\stream_wrapper_register(SubStreams::STREAM_NAME, '\\MailSo\\Base\\StreamWrappers\\SubStreams');
|
\stream_wrapper_register(SubStreams::STREAM_NAME, SubStreams::class);
|
||||||
|
|
|
@ -708,6 +708,7 @@ trait Messages
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Try by default as OpenPGP.js sets GnuPG to 0
|
||||||
if ($this->GetActionParam('GnuPG', 1)) {
|
if ($this->GetActionParam('GnuPG', 1)) {
|
||||||
$GPG = $this->GnuPG();
|
$GPG = $this->GnuPG();
|
||||||
if ($GPG) {
|
if ($GPG) {
|
||||||
|
@ -722,12 +723,13 @@ trait Messages
|
||||||
* https://code.woboq.org/qt5/include/gpg-error.h.html
|
* https://code.woboq.org/qt5/include/gpg-error.h.html
|
||||||
* status:
|
* status:
|
||||||
0 = GPG_ERR_NO_ERROR
|
0 = GPG_ERR_NO_ERROR
|
||||||
|
1 = GPG_ERR_GENERAL
|
||||||
9 = GPG_ERR_NO_PUBKEY
|
9 = GPG_ERR_NO_PUBKEY
|
||||||
117440513 = General error
|
117440513 = General error
|
||||||
117440520 = Bad signature
|
117440520 = Bad signature
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$summary = [
|
$summary = \defined('GNUPG_SIGSUM_VALID') ? [
|
||||||
GNUPG_SIGSUM_VALID => 'The signature is fully valid.',
|
GNUPG_SIGSUM_VALID => 'The signature is fully valid.',
|
||||||
GNUPG_SIGSUM_GREEN => 'The signature is good but one might want to display some extra information. Check the other bits.',
|
GNUPG_SIGSUM_GREEN => 'The signature is good but one might want to display some extra information. Check the other bits.',
|
||||||
GNUPG_SIGSUM_RED => 'The signature is bad. It might be useful to check other bits and display more information, i.e. a revoked certificate might not render a signature invalid when the message was received prior to the cause for the revocation.',
|
GNUPG_SIGSUM_RED => 'The signature is bad. It might be useful to check other bits and display more information, i.e. a revoked certificate might not render a signature invalid when the message was received prior to the cause for the revocation.',
|
||||||
|
@ -740,7 +742,7 @@ trait Messages
|
||||||
GNUPG_SIGSUM_BAD_POLICY => 'A policy requirement was not met.',
|
GNUPG_SIGSUM_BAD_POLICY => 'A policy requirement was not met.',
|
||||||
GNUPG_SIGSUM_SYS_ERROR => 'A system error occurred.',
|
GNUPG_SIGSUM_SYS_ERROR => 'A system error occurred.',
|
||||||
// GNUPG_SIGSUM_TOFU_CONFLICT = 'A TOFU conflict was detected.',
|
// GNUPG_SIGSUM_TOFU_CONFLICT = 'A TOFU conflict was detected.',
|
||||||
];
|
] : [];
|
||||||
|
|
||||||
// Verified, so no need to return $result['text'] and $result['signature']
|
// Verified, so no need to return $result['text'] and $result['signature']
|
||||||
$result = [
|
$result = [
|
||||||
|
@ -1280,14 +1282,17 @@ trait Messages
|
||||||
$GPG = $this->GnuPG();
|
$GPG = $this->GnuPG();
|
||||||
$oBody = $oMessage->GetRootPart();
|
$oBody = $oMessage->GetRootPart();
|
||||||
$resource = $oBody->ToStream();
|
$resource = $oBody->ToStream();
|
||||||
|
|
||||||
|
\MailSo\Base\StreamFilters\LineEndings::appendTo($resource);
|
||||||
|
$fp = \fopen('php://temp', 'r+b');
|
||||||
|
// \stream_copy_to_stream($resource, $fp); // Fails
|
||||||
|
while (!\feof($resource)) \fwrite($fp, \fread($resource, 8192));
|
||||||
|
|
||||||
$oBody->Body = null;
|
$oBody->Body = null;
|
||||||
$oBody->SubParts->Clear();
|
$oBody->SubParts->Clear();
|
||||||
$oMessage->SubParts->Clear();
|
$oMessage->SubParts->Clear();
|
||||||
$oMessage->Attachments()->Clear();
|
$oMessage->Attachments()->Clear();
|
||||||
|
|
||||||
\MailSo\Base\StreamFilters\LineEndings::appendTo($resource);
|
|
||||||
$fp = \fopen('php://temp', 'r+b');
|
|
||||||
\stream_copy_to_stream($resource, $fp);
|
|
||||||
$GPG->addSignKey($sFingerprint, $sPassphrase);
|
$GPG->addSignKey($sFingerprint, $sPassphrase);
|
||||||
$GPG->setsignmode(GNUPG_SIG_MODE_DETACH);
|
$GPG->setsignmode(GNUPG_SIG_MODE_DETACH);
|
||||||
$sSignature = $GPG->signStream($fp);
|
$sSignature = $GPG->signStream($fp);
|
||||||
|
@ -1317,17 +1322,19 @@ trait Messages
|
||||||
if ($aFingerprints) {
|
if ($aFingerprints) {
|
||||||
$GPG = $this->GnuPG();
|
$GPG = $this->GnuPG();
|
||||||
$oBody = $oMessage->GetRootPart();
|
$oBody = $oMessage->GetRootPart();
|
||||||
$fp = \fopen('php://temp', 'r+b');
|
|
||||||
$resource = $oBody->ToStream();
|
$resource = $oBody->ToStream();
|
||||||
\stream_copy_to_stream($resource, $fp);
|
$fp = \fopen('php://temp', 'r+b');
|
||||||
|
// \stream_copy_to_stream($resource, $fp); // Fails
|
||||||
|
while (!\feof($resource)) \fwrite($fp, \fread($resource, 8192));
|
||||||
|
|
||||||
|
$oMessage->SubParts->Clear();
|
||||||
|
$oMessage->Attachments()->Clear();
|
||||||
|
|
||||||
foreach ($aFingerprints as $sFingerprint) {
|
foreach ($aFingerprints as $sFingerprint) {
|
||||||
$GPG->addEncryptKey($sFingerprint);
|
$GPG->addEncryptKey($sFingerprint);
|
||||||
}
|
}
|
||||||
$sEncrypted = $GPG->encryptStream($fp);
|
$sEncrypted = $GPG->encryptStream($fp);
|
||||||
|
|
||||||
$oMessage->SubParts->Clear();
|
|
||||||
$oMessage->Attachments()->Clear();
|
|
||||||
|
|
||||||
$oPart = new MimePart;
|
$oPart = new MimePart;
|
||||||
$oPart->Headers->AddByName(
|
$oPart->Headers->AddByName(
|
||||||
\MailSo\Mime\Enumerations\Header::CONTENT_TYPE,
|
\MailSo\Mime\Enumerations\Header::CONTENT_TYPE,
|
||||||
|
|
Loading…
Reference in a new issue