-
-
Notifications
You must be signed in to change notification settings - Fork 175
Resolves #582 - Default to returning all parts, add allow_single_parts op… #583
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
Open
mrhewitt
wants to merge
1
commit into
Webklex:master
Choose a base branch
from
mrhewitt:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?php | ||
/* | ||
* File: Issue582Test.php | ||
* Category: - | ||
* Author: Mark Hewitt | ||
* Created: 29.05.25 | ||
* Updated: - | ||
* | ||
* Description: | ||
* Test PR and fix for issue 582 and potentially 567/580 and 578 | ||
*/ | ||
|
||
namespace Tests\issues; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Tests\fixtures\FixtureTestCase; | ||
use Webklex\PHPIMAP\Attachment; | ||
use Webklex\PHPIMAP\ClientManager; | ||
use Webklex\PHPIMAP\Exceptions\AuthFailedException; | ||
use Webklex\PHPIMAP\Exceptions\ConnectionFailedException; | ||
use Webklex\PHPIMAP\Exceptions\ImapBadRequestException; | ||
use Webklex\PHPIMAP\Exceptions\ImapServerErrorException; | ||
use Webklex\PHPIMAP\Exceptions\InvalidMessageDateException; | ||
use Webklex\PHPIMAP\Exceptions\MaskNotFoundException; | ||
use Webklex\PHPIMAP\Exceptions\MessageContentFetchingException; | ||
use Webklex\PHPIMAP\Exceptions\ResponseException; | ||
use Webklex\PHPIMAP\Exceptions\RuntimeException; | ||
use Webklex\PHPIMAP\Message; | ||
|
||
class Issue582Test extends FixtureTestCase { | ||
|
||
/** | ||
* @throws RuntimeException | ||
* @throws MessageContentFetchingException | ||
* @throws ResponseException | ||
* @throws ImapBadRequestException | ||
* @throws InvalidMessageDateException | ||
* @throws ConnectionFailedException | ||
* @throws \ReflectionException | ||
* @throws ImapServerErrorException | ||
* @throws AuthFailedException | ||
* @throws MaskNotFoundException | ||
*/ | ||
public function testAttachmentEmail() { | ||
$message = $this->getFixture("issue-582a.eml"); | ||
|
||
self::assertSame("redacted_Balances_GBP_", (string)$message->subject); | ||
|
||
$attachments = $message->getAttachments(); | ||
|
||
self::assertSame(1, $attachments->count()); | ||
|
||
/** @var Attachment $attachment */ | ||
$attachment = $attachments->first(); | ||
self::assertSame("redacted_Balances_GBP_.csv", $attachment->name); | ||
self::assertStringEndsWith("stake_limit,soft_limit,h", $attachment->content); | ||
} | ||
|
||
/** | ||
* @throws RuntimeException | ||
* @throws MessageContentFetchingException | ||
* @throws ResponseException | ||
* @throws ImapBadRequestException | ||
* @throws InvalidMessageDateException | ||
* @throws ConnectionFailedException | ||
* @throws \ReflectionException | ||
* @throws ImapServerErrorException | ||
* @throws AuthFailedException | ||
* @throws MaskNotFoundException | ||
*/ | ||
public function testContentEmail() { | ||
$message = $this->getFixture("issue-582b.eml"); | ||
|
||
self::assertSame("html body in multipart related container is parsed as attachment", (string)$message->subject); | ||
self::assertStringContainsString("This is a message in a multipart related container", $message->getHtmlBody()); | ||
$attachments = $message->getAttachments(); | ||
self::assertSame(0, $attachments->count()); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
Delivered-To: [email protected] | ||
Received: by 2002:a05:7001:a40a:b0:662:9c3d:2d8b with SMTP id | ||
vo10csp4472717mab; Tue, 27 May 2025 00:20:15 -0700 (PDT) | ||
Return-Path: <[email protected]> | ||
From: [email protected] | ||
To: [email protected] | ||
Date: 27 May 2025 08:20:12 +0100 | ||
Subject: redacted_Balances_GBP_ | ||
Content-Type: multipart/mixed; | ||
boundary=--boundary_108_1d32a5ba-d60e-4773-9939-d5614385ac16 | ||
Return-Path: [email protected] | ||
Message-ID: <CWLP123MB51345AE20743EB4587D3CA32AC64A@CWLP123MB5134.GBRP123.PROD.OUTLOOK.COM> | ||
MIME-Version: 1.0 | ||
|
||
----boundary_108_1d32a5ba-d60e-4773-9939-d5614385ac16 | ||
Content-Type: multipart/mixed; | ||
boundary=--boundary_109_fc604310-cc2e-459d-9cb7-9f39cf7d3a80 | ||
|
||
Content-Type: text/html; charset=utf-8 | ||
Content-Transfer-Encoding: quoted-printable | ||
|
||
Single part body | ||
|
||
|
||
----boundary_108_1d32a5ba-d60e-4773-9939-d5614385ac16 | ||
Content-Type: multipart/mixed; | ||
boundary=--boundary_109_fc604310-cc2e-459d-9cb7-9f39cf7d3a80 | ||
|
||
----boundary_109_fc604310-cc2e-459d-9cb7-9f39cf7d3a80 | ||
Content-Type: text/csv; name=redacted_Balances_GBP_.csv | ||
Content-Transfer-Encoding: base64 | ||
Content-Disposition: attachment; | ||
filename="=?utf-8?B?Q2redactedbGFuY2VzX0dCUF8uY3N2?=" | ||
Content-ID: <5df3148f-aa43-4dea-adeb-7d432289d3ea> | ||
|
||
77u/cmVwb3J0X2RhdGUsQ3VycmVuY3ksdXNlcm5hbWUsYWNjb3VudF9zdGF0dXMsY3VycmVudF9i | ||
YWxhbmNlLGxhc3RfdHJhbnNhY3Rpb25fZGF0ZXRpbWUsc3Rha2VfbGltaXQsc29mdF9saW1pdCxo | ||
|
||
----boundary_109_fc604310-cc2e-459d-9cb7-9f39cf7d3a80-- | ||
|
||
----boundary_108_1d32a5ba-d60e-4773-9939-d5614385ac16-- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
Return-Path: <[email protected]> | ||
Date: Thu, 20 Feb 2025 03:44:22 +0100 (CET) | ||
From: [email protected] | ||
To: [email protected], [email protected] | ||
Message-ID: <[email protected]> | ||
Subject: html body in multipart related container is parsed as attachment | ||
MIME-Version: 1.0 | ||
Content-Type: multipart/mixed; | ||
boundary="----=_Part_255_1307735605.1740019462622" | ||
|
||
------=_Part_255_1307735605.1740019462622 | ||
Content-Type: multipart/related; | ||
boundary="----=_Part_256_1484807935.1740019462623" | ||
|
||
------=_Part_256_1484807935.1740019462623 | ||
Content-Type: text/html;charset=UTF-8 | ||
Content-Transfer-Encoding: quoted-printable | ||
|
||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<style> | ||
p { | ||
font-family: "Helvetica Neue", "Segoe UI", Roboto, Arial, sans-serif; | ||
font-size: 13px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<p> | ||
This is a message in a multipart related container | ||
</p> | ||
</body> | ||
</html> | ||
------=_Part_256_1484807935.1740019462623-- | ||
|
||
------=_Part_255_1307735605.1740019462622-- |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
I would suggest to check, if there are some parts, otherwise it will return empty parts
if ( count($parts) > 1 || $config->get("options.allow_single_parts") && count($parts) > 0 ) {
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.
Why not always allow single parts? I think just 'count() == 0' needs to be disregarded.