-
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue with parsing quoted address names #224
- Loading branch information
Showing
4 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -103,6 +103,17 @@ public function testSingleAddressWithEscapedToken() : void | |
$this->assertEquals('[email protected]', $addresses[0]->getValue()); | ||
} | ||
|
||
public function testSingleAddressWithComplexEscapedTokensAndComma() : void | ||
{ | ||
$header = new AddressHeader($this->consumerService, 'From', '"\'\"\\\\\"Test, Recipient\\\\\"\"\'" <[email protected]>'); | ||
$this->assertEquals('[email protected]', $header->getValue()); | ||
$this->assertEquals('\'"\"Test, Recipient\""\'', $header->getPersonName()); | ||
$addresses = $header->getParts(); | ||
$this->assertCount(1, $addresses); | ||
$this->assertEquals('\'"\"Test, Recipient\""\'', $addresses[0]->getName()); | ||
$this->assertEquals('[email protected]', $addresses[0]->getValue()); | ||
} | ||
|
||
public function testMultipleAddresses() : void | ||
{ | ||
$header = new AddressHeader( | ||
|
This file contains 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 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 |
---|---|---|
|
@@ -84,6 +84,18 @@ private function runEmailTestForMessage($message, array $props, $failMessage) : | |
$this->assertEquals($props['To']['name'], $to->getPersonName(), $failMessage); | ||
} | ||
$this->assertEquals($props['To']['email'], $to->getValue(), $failMessage); | ||
} elseif (isset($props['To']) && is_array($props['To']) && isset($props['To'][0]) && isset($props['To'][0]['email'])) { | ||
$to = $message->getHeader('To'); | ||
$addresses = $to->getParts(); | ||
$this->assertCount(count($props['To']), $addresses); | ||
for ($c = 0; $c < count($props['To']); ++$c) { | ||
$exp = $props['To'][$c]; | ||
$act = $addresses[$c]; | ||
if ($exp['name']) { | ||
$this->assertEquals($exp['name'], $act->getName()); | ||
} | ||
$this->assertEquals($exp['email'], $act->getValue()); | ||
} | ||
} | ||
|
||
if (isset($props['From']['email'])) { | ||
|
@@ -1747,6 +1759,28 @@ public function testParseEmailGitHub_115() : void | |
]); | ||
} | ||
|
||
public function testParseEmailGitHub_224() : void | ||
{ | ||
$this->runEmailTest('github-224', [ | ||
'From' => [ | ||
'name' => 'Doug Sauder', | ||
'email' => '[email protected]' | ||
], | ||
'To' => [ | ||
[ | ||
'name' => '\'Test Recipient\'', | ||
'email' => '"success1"@simulator.amazonses.com' | ||
], | ||
[ | ||
'name' => '\'"\"Test, Recipient\""\'', | ||
'email' => '[email protected]' | ||
], | ||
], | ||
'Subject' => 'Die Hasen und die Frösche (Microsoft Outlook 00)', | ||
'text' => 'HasenundFrosche.txt', | ||
]); | ||
} | ||
|
||
public function testRewriteEmailContentm0001() : void | ||
{ | ||
$handle = \fopen($this->messageDir . '/m0001.txt', 'r'); | ||
|
This file contains 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,32 @@ | ||
From: "Doug Sauder" <[email protected]> | ||
To: "'Test Recipient'" <"success1"@simulator.amazonses.com>, "'\"\\\"Test, Recipient\\\"\"'" <[email protected]>, | ||
Subject: Die Hasen und die Fr�sche (Microsoft Outlook 00) | ||
Date: Wed, 17 May 2000 19:08:29 -0400 | ||
Message-ID: <[email protected]> | ||
MIME-Version: 1.0 | ||
contenttype: invalid/application | ||
Content-Type: text/plain; | ||
charset="iso-8859-1" | ||
Content-Transfer-Encoding: 8bit | ||
X-Priority: 3 (Normal) | ||
X-MSMail-Priority: Normal | ||
X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) | ||
Importance: Normal | ||
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 | ||
|
||
Die Hasen und die Fr�sche | ||
|
||
Die Hasen klagten einst �ber ihre mi�liche Lage; "wir leben", sprach ein | ||
Redner, "in steter Furcht vor Menschen und Tieren, eine Beute der Hunde, der | ||
Adler, ja fast aller Raubtiere! Unsere stete Angst ist �rger als der Tod | ||
selbst. Auf, la�t uns ein f�r allemal sterben." | ||
|
||
In einem nahen Teich wollten sie sich nun ers�ufen; sie eilten ihm zu; | ||
allein das au�erordentliche Get�se und ihre wunderbare Gestalt erschreckte | ||
eine Menge Fr�sche, die am Ufer sa�en, so sehr, da� sie aufs schnellste | ||
untertauchten. | ||
|
||
"Halt", rief nun eben dieser Sprecher, "wir wollen das Ers�ufen noch ein | ||
wenig aufschieben, denn auch uns f�rchten, wie ihr seht, einige Tiere, | ||
welche also wohl noch ungl�cklicher sein m�ssen als wir." | ||
|