-
Notifications
You must be signed in to change notification settings - Fork 461
Making into disposition string to lowercase to fix the comparision issue #566
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1249,9 +1249,9 @@ public function getMail(int $mailId, bool $markAsSeen = true): IncomingMail | |
* | ||
* @return IncomingMailAttachment $attachment | ||
*/ | ||
public function downloadAttachment(DataPartInfo $dataInfo, array $params, object $partStructure, bool $emlOrigin = false): IncomingMailAttachment | ||
public function downloadAttachment(DataPartInfo $dataInfo, array $params, object $partStructure, bool $emlOrigin = false, bool $dispositionAttachment = false): IncomingMailAttachment | ||
{ | ||
if ('RFC822' == $partStructure->subtype && isset($partStructure->disposition) && 'attachment' == $partStructure->disposition) { | ||
if ('RFC822' == $partStructure->subtype && isset($partStructure->disposition) && $dispositionAttachment) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm still not sure, if this is a good replacement. I think, this will break (also) something. Before: string comparisation There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function skipped attachments in some emails due to case sensitive comparison. |
||
$fileName = \strtolower($partStructure->subtype).'.eml'; | ||
} elseif ('ALTERNATIVE' == $partStructure->subtype) { | ||
$fileName = \strtolower($partStructure->subtype).'.eml'; | ||
|
@@ -1674,10 +1674,10 @@ protected function initMailPart(IncomingMail $mail, object $partStructure, $part | |
} | ||
|
||
// check if the part is a subpart of another attachment part (RFC822) | ||
if ('RFC822' === $partStructure->subtype && isset($partStructure->disposition) && 'attachment' === $partStructure->disposition) { | ||
if ('RFC822' === $partStructure->subtype && isset($partStructure->disposition) && $dispositionAttachment) { | ||
// Although we are downloading each part separately, we are going to download the EML to a single file | ||
//incase someone wants to process or parse in another process | ||
$attachment = self::downloadAttachment($dataInfo, $params, $partStructure, false); | ||
$attachment = self::downloadAttachment($dataInfo, $params, $partStructure, false, $dispositionAttachment); | ||
$mail->addAttachment($attachment); | ||
} | ||
|
||
|
@@ -1695,7 +1695,7 @@ protected function initMailPart(IncomingMail $mail, object $partStructure, $part | |
} | ||
|
||
if ($isAttachment) { | ||
$attachment = self::downloadAttachment($dataInfo, $params, $partStructure, $emlParse); | ||
$attachment = self::downloadAttachment($dataInfo, $params, $partStructure, $emlParse, $dispositionAttachment); | ||
$mail->addAttachment($attachment); | ||
} else { | ||
if (isset($params['charset']) && !empty(\trim($params['charset']))) { | ||
|
@@ -1705,14 +1705,14 @@ protected function initMailPart(IncomingMail $mail, object $partStructure, $part | |
|
||
if (!empty($partStructure->parts)) { | ||
foreach ($partStructure->parts as $subPartNum => $subPartStructure) { | ||
$not_attachment = (!isset($partStructure->disposition) || 'attachment' !== $partStructure->disposition); | ||
$not_attachment = (!isset($partStructure->disposition) || !$dispositionAttachment); | ||
|
||
if (TYPEMESSAGE === $partStructure->type && 'RFC822' === $partStructure->subtype && $not_attachment) { | ||
$this->initMailPart($mail, $subPartStructure, $partNum, $markAsSeen); | ||
} elseif (TYPEMULTIPART === $partStructure->type && 'ALTERNATIVE' === $partStructure->subtype && $not_attachment) { | ||
// https://github.com/barbushin/php-imap/issues/198 | ||
$this->initMailPart($mail, $subPartStructure, $partNum, $markAsSeen); | ||
} elseif ('RFC822' === $partStructure->subtype && isset($partStructure->disposition) && 'attachment' === $partStructure->disposition) { | ||
} elseif ('RFC822' === $partStructure->subtype && isset($partStructure->disposition) && $dispositionAttachment) { | ||
//If it comes from am EML attachment, download each part separately as a file | ||
$this->initMailPart($mail, $subPartStructure, $partNum.'.'.($subPartNum + 1), $markAsSeen, true); | ||
} else { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are adding a new argument here and set it by default to
false
, but it seems like as it's never used, so it's alwaysfalse
. Isn't it?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, please see the whole changed function not only my changes.