Enigma: Fix malformed signed messages with force_7bit=true (#5292)

pull/5303/head
Aleksander Machniak 9 years ago
parent d61d33a12a
commit 96102e2052

@ -19,6 +19,7 @@ CHANGELOG Roundcube Webmail
- Fix bug where multi-folder search didn't work for unsubscribed INBOX (#5259) - Fix bug where multi-folder search didn't work for unsubscribed INBOX (#5259)
- Fix bug where "no body" alert could be displayed when sending mailvelope email - Fix bug where "no body" alert could be displayed when sending mailvelope email
- Enigma: Fix keys import from inside of an encrypted message (#5285) - Enigma: Fix keys import from inside of an encrypted message (#5285)
- Enigma: Fix malformed signed messages with force_7bit=true (#5292)
- Fix searching by email address in contacts with multiple addresses (#5291) - Fix searching by email address in contacts with multiple addresses (#5291)
- Fix handling of --delete argument in moduserprefs.sh script (#5296) - Fix handling of --delete argument in moduserprefs.sh script (#5296)

@ -3,7 +3,7 @@
"type": "roundcube-plugin", "type": "roundcube-plugin",
"description": "PGP Encryption for Roundcube", "description": "PGP Encryption for Roundcube",
"license": "GPLv3+", "license": "GPLv3+",
"version": "0.5", "version": "0.6",
"authors": [ "authors": [
{ {
"name": "Aleksander Machniak", "name": "Aleksander Machniak",

@ -126,7 +126,9 @@ class enigma_mime_message extends Mail_mime
$_headers = $this->message->headers(); $_headers = $this->message->headers();
$headers = array(); $headers = array();
if ($_headers['Content-Transfer-Encoding']) { if ($_headers['Content-Transfer-Encoding']
&& stripos($_headers['Content-Type'], 'multipart') === false
) {
$headers[] = 'Content-Transfer-Encoding: ' . $_headers['Content-Transfer-Encoding']; $headers[] = 'Content-Transfer-Encoding: ' . $_headers['Content-Transfer-Encoding'];
} }
$headers[] = 'Content-Type: ' . $_headers['Content-Type']; $headers[] = 'Content-Type: ' . $_headers['Content-Type'];
@ -142,8 +144,10 @@ class enigma_mime_message extends Mail_mime
public function addPGPSignature($body) public function addPGPSignature($body)
{ {
$this->signature = $body; $this->signature = $body;
// Reset Content-Type to be overwritten with valid boundary // Reset Content-Type to be overwritten with valid boundary
unset($this->headers['Content-Type']); unset($this->headers['Content-Type']);
unset($this->headers['Content-Transfer-Encoding']);
} }
/** /**
@ -154,8 +158,10 @@ class enigma_mime_message extends Mail_mime
public function setPGPEncryptedBody($body) public function setPGPEncryptedBody($body)
{ {
$this->encrypted = $body; $this->encrypted = $body;
// Reset Content-Type to be overwritten with valid boundary // Reset Content-Type to be overwritten with valid boundary
unset($this->headers['Content-Type']); unset($this->headers['Content-Type']);
unset($this->headers['Content-Transfer-Encoding']);
} }
/** /**
@ -193,7 +199,9 @@ class enigma_mime_message extends Mail_mime
$headers = $this->message->headers(); $headers = $this->message->headers();
$params = array('content_type' => $headers['Content-Type']); $params = array('content_type' => $headers['Content-Type']);
if ($headers['Content-Transfer-Encoding']) { if ($headers['Content-Transfer-Encoding']
&& stripos($headers['Content-Type'], 'multipart') === false
) {
$params['encoding'] = $headers['Content-Transfer-Encoding']; $params['encoding'] = $headers['Content-Transfer-Encoding'];
} }
@ -243,18 +251,24 @@ class enigma_mime_message extends Mail_mime
if ($filename) { if ($filename) {
// Append mimePart message headers and body into file // Append mimePart message headers and body into file
$headers = $message->encodeToFile($filename, $boundary, $skip_head); $headers = $message->encodeToFile($filename, $boundary, $skip_head);
if ($this->isError($headers)) { if ($this->isError($headers)) {
return $headers; return $headers;
} }
$this->headers = array_merge($this->headers, $headers); $this->headers = array_merge($this->headers, $headers);
return null;
return;
} }
else { else {
$output = $message->encode($boundary, $skip_head); $output = $message->encode($boundary, $skip_head);
if ($this->isError($output)) { if ($this->isError($output)) {
return $output; return $output;
} }
$this->headers = array_merge($this->headers, $output['headers']); $this->headers = array_merge($this->headers, $output['headers']);
return $output['body']; return $output['body'];
} }
} }

@ -968,19 +968,19 @@ class enigma_ui
} }
if (!$savedraft && $pubkey_enable) { if (!$savedraft && $pubkey_enable) {
$this->enigma->load_engine(); $engine = $this->enigma->load_engine();
$this->enigma->engine->attach_public_key($p['message']); $engine->attach_public_key($p['message']);
} }
if (!$savedraft && $sign_enable) { if (!$savedraft && $sign_enable) {
$this->enigma->load_engine(); $engine = $this->enigma->load_engine();
$status = $this->enigma->engine->sign_message($p['message']); $status = $engine->sign_message($p['message']);
$mode = 'sign'; $mode = 'sign';
} }
if ((!$status instanceof enigma_error) && $encrypt_enable) { if ((!$status instanceof enigma_error) && $encrypt_enable) {
$this->enigma->load_engine(); $engine = $this->enigma->load_engine();
$status = $this->enigma->engine->encrypt_message($p['message'], null, $savedraft); $status = $engine->encrypt_message($p['message'], null, $savedraft);
$mode = 'encrypt'; $mode = 'encrypt';
} }

Loading…
Cancel
Save