Skip to content

Commit 88e65a8

Browse files
committed
Address decoding error detection added #388
1 parent 63f26f6 commit 88e65a8

File tree

4 files changed

+58
-0
lines changed

4 files changed

+58
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip
2626
- Check if the next uid is available (after copying or moving a message) before fetching it #381
2727
- Default pagination `$total` attribute value set to 0 #385 (thanks @hhniao)
2828
- Use attachment ID as fallback filename for saving an attachment
29+
- Address decoding error detection added #388
2930

3031
### Added
3132
- Extended UTF-7 support added (RFC2060) #383

src/Header.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,13 @@ private function parseAddresses($list): array {
583583
}
584584
}
585585

586+
if ($address->host == ".SYNTAX-ERROR.") {
587+
$address->host = "";
588+
}
589+
if ($address->mailbox == "UNEXPECTED_DATA_AFTER_ADDRESS") {
590+
$address->mailbox = "";
591+
}
592+
586593
$address->mail = ($address->mailbox && $address->host) ? $address->mailbox . '@' . $address->host : false;
587594
$address->full = ($address->personal) ? $address->personal . ' <' . $address->mail . '>' : $address->mail;
588595

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
/*
3+
* File: UndisclosedRecipientsTest.php
4+
* Category: -
5+
* Author: M.Goldenbaum
6+
* Created: 09.03.23 02:24
7+
* Updated: -
8+
*
9+
* Description:
10+
* -
11+
*/
12+
13+
namespace Tests\fixtures;
14+
15+
/**
16+
* Class UndisclosedRecipientsTest
17+
*
18+
* @package Tests\fixtures
19+
*/
20+
class UndisclosedRecipientsTest extends FixtureTestCase {
21+
22+
/**
23+
* Test the fixture undisclosed_recipients.eml
24+
*
25+
* @return void
26+
*/
27+
public function testFixture() : void {
28+
$message = $this->getFixture("undisclosed_recipients.eml");
29+
30+
self::assertEquals("test", $message->subject);
31+
self::assertEquals("Hi!", $message->getTextBody());
32+
self::assertFalse($message->hasHTMLBody());
33+
self::assertEquals("2017-09-27 10:48:51", $message->date->first()->setTimezone('UTC')->format("Y-m-d H:i:s"));
34+
self::assertEquals("[email protected]", $message->from);
35+
self::assertEquals([
36+
"Undisclosed Recipients",
37+
""
38+
], $message->to->map(function ($item) {
39+
return $item->mailbox;
40+
}));
41+
}
42+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Subject: test
2+
MIME-Version: 1.0
3+
Content-Type: text/plain
4+
Date: Wed, 27 Sep 2017 12:48:51 +0200
5+
6+
To: "Undisclosed Recipients" <>
7+
8+
Hi!

0 commit comments

Comments
 (0)