From 2ed34a39c64ef89fe142e2d74514f26bd80be46c Mon Sep 17 00:00:00 2001 From: ralf Date: Wed, 20 Mar 2024 12:51:39 +0200 Subject: [PATCH] * Mail: fix forwarding and reply to mail with just a PDF or image was showing it and not opening a compose window --- api/src/Mail.php | 6 ++++-- mail/inc/class.mail_compose.inc.php | 12 +++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/api/src/Mail.php b/api/src/Mail.php index 4c4e3439b3..4c13aea489 100644 --- a/api/src/Mail.php +++ b/api/src/Mail.php @@ -4961,9 +4961,11 @@ class Mail * @param boolean $_preserveSeen flag to preserve the seenflag by using body.peek * @param string $_folder folder to work on * @param Horde_Mime_part& $calendar_part =null on return calendar-part or null, if there is none + * @param bool $output_no_body true: if we have no "real" body, but a PDF or image, output it to display, false: return empty body * @return array containing the message body, mimeType and charset */ - function getMessageBody($_uid, $_htmlOptions='', $_partID=null, Horde_Mime_Part $_structure=null, $_preserveSeen = false, $_folder = '', &$calendar_part=null) + function getMessageBody($_uid, $_htmlOptions='', $_partID=null, Horde_Mime_Part $_structure=null, $_preserveSeen = false, + $_folder = '', &$calendar_part=null, bool $output_no_body=true) { if (self::$debug) echo __METHOD__."$_uid, $_htmlOptions, $_partID
"; if($_htmlOptions != '') { @@ -5001,7 +5003,7 @@ class Mail } // if message is just a pdf, return it to browser to display - if ($_structure->getType() === 'application/pdf' || $_structure->getPrimaryType() === 'image') + if ($output_no_body && ($_structure->getType() === 'application/pdf' || $_structure->getPrimaryType() === 'image')) { header('Content-Type: '.$_structure->getType()); echo $this->getAttachment($_uid, $_partID ?? '1', 0, true, $_folder)->getContents(); diff --git a/mail/inc/class.mail_compose.inc.php b/mail/inc/class.mail_compose.inc.php index 3c97d3f06a..4545a1cfaf 100644 --- a/mail/inc/class.mail_compose.inc.php +++ b/mail/inc/class.mail_compose.inc.php @@ -326,7 +326,7 @@ class mail_compose $_contentHasSigID = $_content?array_key_exists('mailidentity',(array)$_content):false; $_contentHasMimeType = $_content? array_key_exists('mimeType',(array)$_content):false; - // fetch appendix data which is an assistance input value consisiting of json data + // fetch appendix data which is an assistance input value consisting of json data if (!empty($_content['appendix_data'])) { $appendix_data = json_decode($_content['appendix_data'], true); @@ -2283,7 +2283,8 @@ class mail_compose //_debug_array($headers); //error_log(__METHOD__.__LINE__.'->'.array2string($this->mailPreferences['htmlOptions'])); try { - $bodyParts = $mail_bo->getMessageBody($_uid, ($this->mailPreferences['htmlOptions']?$this->mailPreferences['htmlOptions']:''), $_partID); + $bodyParts = $mail_bo->getMessageBody($_uid, $this->mailPreferences['htmlOptions']??'', $_partID, + null, false, '', $nul, false); } catch (Mail\Smime\PassphraseMissing $e) { @@ -2374,11 +2375,8 @@ class mail_compose $this->sessionData['body'] .= "\r\n"; $hasSignature = false; // create body new, with good line breaks and indention - foreach(explode("\n",$newBody) as $value) { - // the explode is removing the character - //$value .= 'ee'; - - // Try to remove signatures from qouted parts to avoid multiple + foreach($newBody ? explode("\n",$newBody) : [] as $value) { + // Try to remove signatures from quoted parts to avoid multiple // signatures problem in reply (rfc3676#section-4.3). if ($_mode != 'forward' && ($hasSignature || ($hasSignature = preg_match("/^--\s[\r\n]$/",$value)))) {