From 0eb3ba50f28ff3ffc169f6bc7a8ca22dd39c55eb Mon Sep 17 00:00:00 2001 From: OpenXE <> Date: Wed, 1 Feb 2023 11:24:20 +0100 Subject: [PATCH] Ticket system some fixes where the attachment filename could not be read --- .../MailClient/Data/MailAttachmentData.php | 20 ++++++++++++++----- .../MailClient/Data/MailMessagePartData.php | 5 +++-- .../src/Header/ContentDisposition.php | 3 ++- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/classes/Components/MailClient/Data/MailAttachmentData.php b/classes/Components/MailClient/Data/MailAttachmentData.php index fe414934..c9893eaf 100644 --- a/classes/Components/MailClient/Data/MailAttachmentData.php +++ b/classes/Components/MailClient/Data/MailAttachmentData.php @@ -60,6 +60,9 @@ class MailAttachmentData implements MailAttachmentInterface */ public static function fromMailMessagePart(MailMessagePartInterface $part): MailAttachmentData { + + $isInline = false; + $encodingHeader = $part->getHeader('content-transfer-encoding'); if ($encodingHeader === null) { // Assume this is no error (?) throw new InvalidArgumentException('missing header: "Content-Transfer-Encoding"'); @@ -112,7 +115,7 @@ class MailAttachmentData implements MailAttachmentInterface } else if ($disposition == 'inline') { $isInline = true; - $filename = ""; // This is questionable + $filename = "OpenXE_file.inline"; } else if (strpos($disposition,'attachment;\n') == 0) { // No filename, check for content type message/rfc822 @@ -123,12 +126,12 @@ class MailAttachmentData implements MailAttachmentInterface $contenttype = $contenttypeHeader->getValue(); if ($contenttype == 'message/rfc822') { - $isInline = false; $filename = 'ForwardedMessage.eml'; } else { - throw new InvalidArgumentException( + /* throw new InvalidArgumentException( sprintf('unexpected header value "Content-Disposition" = "%s"', $disposition) - ); + );*/ + $filename = "OpenXE_file.unknown"; } } else { @@ -155,9 +158,16 @@ class MailAttachmentData implements MailAttachmentInterface } } + $content = $part->getContent(); + if ($content === null) { // This should not be + throw new InvalidArgumentException( + sprintf('content is null "%s"', print_r($part,true)) + ); + } + return new self( $filename, - $part->getContent(), + $content, $part->getContentType(), $encoding, $isInline, diff --git a/classes/Components/MailClient/Data/MailMessagePartData.php b/classes/Components/MailClient/Data/MailMessagePartData.php index 8210ff71..c974ebad 100644 --- a/classes/Components/MailClient/Data/MailMessagePartData.php +++ b/classes/Components/MailClient/Data/MailMessagePartData.php @@ -153,8 +153,9 @@ final class MailMessagePartData implements MailMessagePartInterface, JsonSeriali if ($encodingHeader === null ) { $result = $this->content; } - - $result = $this->decode($this->content, $encodingHeader->getValue()); + else { + $result = $this->decode($this->content, $encodingHeader->getValue()); + } $charset = $this->getCharset(); diff --git a/vendor/laminas/laminas-mail/src/Header/ContentDisposition.php b/vendor/laminas/laminas-mail/src/Header/ContentDisposition.php index 5066ddeb..a0cfaeee 100644 --- a/vendor/laminas/laminas-mail/src/Header/ContentDisposition.php +++ b/vendor/laminas/laminas-mail/src/Header/ContentDisposition.php @@ -18,7 +18,8 @@ class ContentDisposition implements UnstructuredInterface * * @var int */ - const MAX_PARAMETER_LENGTH = 76; +// const MAX_PARAMETER_LENGTH = 76; // This is the RECOMMENDATION + const MAX_PARAMETER_LENGTH = 996; // This is the LIMIT /** * @var string