Skip to content

Commit

Permalink
Merge pull request Z-Hub#89 from dallaslu/patch-2
Browse files Browse the repository at this point in the history
fixed Z-Hub#88 PGP and S/MIME encryption
  • Loading branch information
matidau authored Aug 8, 2024
2 parents 39fcaa8 + 64596c7 commit 12a6300
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions src/include/mimeDecode.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,25 +330,12 @@ function _decode($headers, $body, $default_ctype = 'text/plain')
if (isset($content_type)) {
switch (strtolower($content_type['value'])) {
case 'text/plain':
$encoding = isset($content_transfer_encoding) ? $content_transfer_encoding['value'] : '7bit';
$charset = isset($return->ctype_parameters['charset']) ? $return->ctype_parameters['charset'] : $this->_charset;
$this->_include_bodies ? $return->body = ($this->_decode_bodies ? $this->_decodeBody($body, $encoding, $charset, true) : $body) : null;
break;

case 'text/html':
$encoding = isset($content_transfer_encoding) ? $content_transfer_encoding['value'] : '7bit';
$charset = isset($return->ctype_parameters['charset']) ? $return->ctype_parameters['charset'] : $this->_charset;
$this->_include_bodies ? $return->body = ($this->_decode_bodies ? $this->_decodeBody($body, $encoding, $charset, true) : $body) : null;
break;

case 'multipart/signed': // PGP
$parts = $this->_boundarySplit($body, $content_type['other']['boundary'], true);
$return->parts['msg_body'] = $parts[0];
list($part_header, $part_body) = $this->_splitBodyHeader($parts[1]);
$return->parts['sig_hdr'] = $part_header;
$return->parts['sig_body'] = $part_body;
break;


case 'multipart/encrypted': // #190 encrypted parts will be treated as normal ones
case 'multipart/parallel':
case 'multipart/appledouble': // Appledouble mail
Expand All @@ -367,7 +354,7 @@ function _decode($headers, $body, $default_ctype = 'text/plain')

$default_ctype = (strtolower($content_type['value']) === 'multipart/digest') ? 'message/rfc822' : 'text/plain';

$parts = $this->_boundarySplit($body, $content_type['other']['boundary']);
$parts = $this->_boundarySplit($body, $content_type['other']['boundary'], strtolower($content_type['value']) === 'multipart/signed');
for ($i = 0; $i < count($parts); $i++) {
list($part_header, $part_body) = $this->_splitBodyHeader($parts[$i]);
$part = $this->_decode($part_header, $part_body, $default_ctype);
Expand Down

0 comments on commit 12a6300

Please sign in to comment.