diff options
author | Aleksander Machniak <alec@alec.pl> | 2021-03-06 10:52:23 +0300 |
---|---|---|
committer | Aleksander Machniak <alec@alec.pl> | 2021-03-06 11:03:47 +0300 |
commit | cbb8cfcb29afd7a83a5d08cef1eb7ec2db645abc (patch) | |
tree | e9b9310afdf7bf0e6487eb7aa92db516687972fd | |
parent | e1af03c8a46e568a0ead223c2223910402fa81c6 (diff) |
Enigma: Fix bug where signature verification could fail for non-ascii bodies (#7919)
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | plugins/enigma/lib/enigma_engine.php | 13 |
2 files changed, 9 insertions, 5 deletions
@@ -1,6 +1,7 @@ CHANGELOG Roundcube Webmail =========================== +- Enigma: Fix bug where signature verification could fail for non-ascii bodies (#7919) - Fix bug causing some HTML message content to be not centered in Elastic skin (#7911) RELEASE 1.4.11 diff --git a/plugins/enigma/lib/enigma_engine.php b/plugins/enigma/lib/enigma_engine.php index 0f420bbe8..4dbb464a5 100644 --- a/plugins/enigma/lib/enigma_engine.php +++ b/plugins/enigma/lib/enigma_engine.php @@ -874,6 +874,10 @@ class enigma_engine private function pgp_verify(&$msg_body, $sig_body = null) { // @TODO: Handle big bodies using (temp) files + + // Get rid of possible non-ascii characters (#5962) + $sig_body = preg_replace('/[^\x00-\x7F]/', '', $sig_body); + $sig = $this->pgp_driver->verify($msg_body, $sig_body); if (($sig instanceof enigma_error) && $sig->getCode() != enigma_error::KEYNOTFOUND) { @@ -894,6 +898,10 @@ class enigma_engine private function pgp_decrypt(&$msg_body, &$signature = null) { // @TODO: Handle big bodies using (temp) files + + // Get rid of possible non-ascii characters (#5962) + $msg_body = preg_replace('/[^\x00-\x7F]/', '', $msg_body); + $keys = $this->get_passwords(); $result = $this->pgp_driver->decrypt($msg_body, $keys, $signature); @@ -1227,11 +1235,6 @@ class enigma_engine } else { $body = $msg->get_part_body($part->mime_id, false); - - // Convert charset to get rid of possible non-ascii characters (#5962) - if ($part->charset && stripos($part->charset, 'ASCII') === false) { - $body = rcube_charset::convert($body, $part->charset, 'US-ASCII'); - } } return $body; |