Skip to content

Commit

Permalink
Address decoding error detection added #388
Browse files Browse the repository at this point in the history
  • Loading branch information
Webklex committed Mar 15, 2023
1 parent 63f26f6 commit 88e65a8
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip
- Check if the next uid is available (after copying or moving a message) before fetching it #381
- Default pagination `$total` attribute value set to 0 #385 (thanks @hhniao)
- Use attachment ID as fallback filename for saving an attachment
- Address decoding error detection added #388

### Added
- Extended UTF-7 support added (RFC2060) #383
Expand Down
7 changes: 7 additions & 0 deletions src/Header.php
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,13 @@ private function parseAddresses($list): array {
}
}

if ($address->host == ".SYNTAX-ERROR.") {
$address->host = "";
}
if ($address->mailbox == "UNEXPECTED_DATA_AFTER_ADDRESS") {
$address->mailbox = "";
}

$address->mail = ($address->mailbox && $address->host) ? $address->mailbox . '@' . $address->host : false;
$address->full = ($address->personal) ? $address->personal . ' <' . $address->mail . '>' : $address->mail;

Expand Down
42 changes: 42 additions & 0 deletions tests/fixtures/UndisclosedRecipientsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php
/*
* File: UndisclosedRecipientsTest.php
* Category: -
* Author: M.Goldenbaum
* Created: 09.03.23 02:24
* Updated: -
*
* Description:
* -
*/

namespace Tests\fixtures;

/**
* Class UndisclosedRecipientsTest
*
* @package Tests\fixtures
*/
class UndisclosedRecipientsTest extends FixtureTestCase {

/**
* Test the fixture undisclosed_recipients.eml
*
* @return void
*/
public function testFixture() : void {
$message = $this->getFixture("undisclosed_recipients.eml");

self::assertEquals("test", $message->subject);
self::assertEquals("Hi!", $message->getTextBody());
self::assertFalse($message->hasHTMLBody());
self::assertEquals("2017-09-27 10:48:51", $message->date->first()->setTimezone('UTC')->format("Y-m-d H:i:s"));
self::assertEquals("[email protected]", $message->from);
self::assertEquals([
"Undisclosed Recipients",
""
], $message->to->map(function ($item) {
return $item->mailbox;
}));
}
}
8 changes: 8 additions & 0 deletions tests/messages/undisclosed_recipients.eml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Subject: test
MIME-Version: 1.0
Content-Type: text/plain
Date: Wed, 27 Sep 2017 12:48:51 +0200
From: [email protected]
To: "Undisclosed Recipients" <>

Hi!

0 comments on commit 88e65a8

Please sign in to comment.