Cleaner DoMessagePgpVerify result

This commit is contained in:
the-djmaze 2022-01-18 15:08:07 +01:00
parent 7ef1a8f14a
commit 87548632a9

View file

@ -682,26 +682,26 @@ trait Messages
if ($sSigPartId) { if ($sSigPartId) {
$result = [ $result = [
'Text' => \preg_replace('/\\R/s', "\r\n", 'text' => \preg_replace('/\\R/s', "\r\n",
$oFetchResponse->GetFetchValue(FetchType::BODY.'['.$sBodyPartId.'.MIME]') $oFetchResponse->GetFetchValue(FetchType::BODY.'['.$sBodyPartId.'.MIME]')
. $oFetchResponse->GetFetchValue(FetchType::BODY.'['.$sBodyPartId.']') . $oFetchResponse->GetFetchValue(FetchType::BODY.'['.$sBodyPartId.']')
), ),
'Signature' => preg_replace('/[^\x00-\x7F]/', '', 'signature' => preg_replace('/[^\x00-\x7F]/', '',
$oFetchResponse->GetFetchValue(FetchType::BODY.'['.$sSigPartId.']') $oFetchResponse->GetFetchValue(FetchType::BODY.'['.$sSigPartId.']')
) )
]; ];
} else { } else {
// clearsigned text // clearsigned text
$result = [ $result = [
'Text' => \preg_replace('/\\R/s', "\r\n", 'text' => \preg_replace('/\\R/s', "\r\n",
$oFetchResponse->GetFetchValue(FetchType::BODY.'['.$sBodyPartId.']') $oFetchResponse->GetFetchValue(FetchType::BODY.'['.$sBodyPartId.']')
), ),
'Signature' => false 'signature' => false
]; ];
} }
if (\class_exists('gnupg')) { if (\class_exists('gnupg')) {
$info = $this->GnuPG()->verify($result['Text'], $result['Signature'])[0]; $info = $this->GnuPG()->verify($result['text'], $result['signature'])[0];
/** /**
* https://code.woboq.org/qt5/include/gpg-error.h.html * https://code.woboq.org/qt5/include/gpg-error.h.html
@ -727,9 +727,8 @@ trait Messages
// 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 = [
'Result' => [
'fingerprint' => $info['fingerprint'], 'fingerprint' => $info['fingerprint'],
'validity' => $info['validity'], 'validity' => $info['validity'],
'status' => $info['status'], 'status' => $info['status'],
@ -737,7 +736,6 @@ trait Messages
'message' => \implode("\n", \array_filter($summary, function($k) use ($info) { 'message' => \implode("\n", \array_filter($summary, function($k) use ($info) {
return $info['summary'] & $k; return $info['summary'] & $k;
}, ARRAY_FILTER_USE_KEY)) }, ARRAY_FILTER_USE_KEY))
]
]; ];
} }