-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix displaying message/rfc822 parts (#9753)
* Fix displaying message/rfc822 parts The previous code contained a simple error that assigned the body part to the $headers variable (which then couldn't be parsed and got discarded). * Test rendering of attached message/rfc822 parts
- Loading branch information
Showing
3 changed files
with
126 additions
and
3 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
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,49 @@ | ||
<?php | ||
|
||
namespace Tests\MessageRendering; | ||
|
||
/** | ||
* Test class to test simple messages. | ||
*/ | ||
class MessageRfc822Test extends MessageRenderingTestCase | ||
{ | ||
public function testRfc822Part() | ||
{ | ||
$domxpath = $this->runAndGetHtmlOutputDomxpath('[email protected]'); | ||
$this->assertSame('Fwd: Lines', $this->getScrubbedSubject($domxpath)); | ||
|
||
$parts = $domxpath->query('//div[@id="messagebody"]/div'); | ||
$this->assertCount(3, $parts); | ||
$this->assertSame('message-part', $parts[0]->attributes->getNamedItem('class')->textContent); | ||
$this->assertSame('Check the forwarded message', $parts[0]->textContent); | ||
$this->assertSame('message-part', $parts[2]->attributes->getNamedItem('class')->textContent); | ||
$this->assertStringStartsWith('Plain text message body.', $parts[2]->textContent); | ||
|
||
$this->assertSame('message-partheaders', $parts[1]->attributes->getNamedItem('class')->textContent); | ||
|
||
$msgRfc822Subject = $domxpath->query('//div[@class="message-partheaders"]//td[@class="header subject"]'); | ||
$this->assertCount(1, $msgRfc822Subject); | ||
$this->assertSame('Lines', $msgRfc822Subject[0]->textContent); | ||
|
||
$msgRfc822From = $domxpath->query('//div[@class="message-partheaders"]//td[@class="header from"]'); | ||
$this->assertCount(1, $msgRfc822From); | ||
$this->assertSame('Thomas B.', $msgRfc822From[0]->textContent); | ||
|
||
$msgRfc822To = $domxpath->query('//div[@class="message-partheaders"]//td[@class="header to"]'); | ||
$this->assertCount(1, $msgRfc822To); | ||
$this->assertSame('Tom Tester', $msgRfc822To[0]->textContent); | ||
|
||
$msgRfc822Cc = $domxpath->query('//div[@class="message-partheaders"]//td[@class="header cc"]'); | ||
$this->assertCount(1, $msgRfc822Cc); | ||
$this->assertSame('[email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]', $msgRfc822Cc[0]->textContent); | ||
|
||
$msgRfc822ReplyTo = $domxpath->query('//div[@class="message-partheaders"]//td[@class="header mail-reply-to"]'); | ||
$this->assertCount(1, $msgRfc822ReplyTo); | ||
$this->assertSame('[email protected]', $msgRfc822ReplyTo[0]->textContent); | ||
|
||
$msgRfc822Date = $domxpath->query('//div[@class="message-partheaders"]//td[@class="header date"]'); | ||
$this->assertCount(1, $msgRfc822Date); | ||
// Using a RegExp here, because the result is different depending on the timezone of the testing environment. | ||
$this->assertMatchesRegularExpression('/2014-05-2[234]{1} \d{2}:\d{2}/', $msgRfc822Date[0]->textContent); | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
tests/MessageRendering/data/greenmail/test-message-rendering@localhost/INBOX/fwd_lines.eml
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,74 @@ | ||
MIME-Version: 1.0 | ||
Date: Wed, 15 Jan 2025 11:44:00 +0100 | ||
From: [email protected] | ||
To: [email protected] | ||
Subject: Fwd: Lines | ||
In-Reply-To: <[email protected]> | ||
References: <[email protected]> | ||
Message-ID: <[email protected]> | ||
X-Sender: [email protected] | ||
X-Draft-Info: type=forward; uid=3; folder=B::SU5CT1g= | ||
Content-Type: multipart/mixed; | ||
boundary="=_9b038d50a3b2b5cfe9fdbd53743b1ea9" | ||
|
||
--=_9b038d50a3b2b5cfe9fdbd53743b1ea9 | ||
Content-Transfer-Encoding: 7bit | ||
Content-Type: text/plain; charset=US-ASCII; | ||
format=flowed | ||
Check the forwarded message | ||
--=_9b038d50a3b2b5cfe9fdbd53743b1ea9 | ||
Content-Transfer-Encoding: 8bit | ||
Content-Type: message/rfc822; | ||
name=Lines.eml | ||
Content-Disposition: attachment; | ||
filename=Lines.eml; | ||
size=1382 | ||
Return-Path: <[email protected]> | ||
X-Original-To: [email protected] | ||
From: "Thomas B." <[email protected]> | ||
To: Tom Tester <[email protected]> | ||
Subject: Lines | ||
Cc: [email protected], [email protected], [email protected], [email protected], | ||
[email protected], [email protected], [email protected], [email protected], | ||
[email protected], [email protected], [email protected], [email protected] | ||
MIME-Version: 1.0 | ||
Content-Type: multipart/mixed; | ||
boundary="=_8853bfb47b7da1852ac882e69cc724f3" | ||
Date: Fri, 23 May 2014 19:44:50 +0200 | ||
Reply-To: [email protected] | ||
Mail-Reply-To: [email protected] | ||
Message-ID: <[email protected]> | ||
X-Sender: [email protected] | ||
--=_8853bfb47b7da1852ac882e69cc724f3 | ||
Content-Transfer-Encoding: 7bit | ||
Content-Type: text/plain; charset=UTF-8; | ||
format=flowed | ||
Plain text message body. | ||
-- | ||
Developer of Free Software | ||
Sent with Roundcube Webmail - roundcube.net | ||
--=_8853bfb47b7da1852ac882e69cc724f3 | ||
Content-Transfer-Encoding: base64 | ||
Content-Type: text/plain; | ||
name=lines.txt | ||
Content-Disposition: attachment; | ||
filename=lines.txt; | ||
size=13 | ||
Zm9vDQpiYXINCmduYQ== | ||
--=_8853bfb47b7da1852ac882e69cc724f3 | ||
Content-Transfer-Encoding: base64 | ||
Content-Type: text/plain; | ||
name=lines_lf.txt | ||
Content-Disposition: attachment; | ||
filename=lines_lf.txt; | ||
size=11 | ||
Zm9vCmJhcgpnbmE= | ||
--=_8853bfb47b7da1852ac882e69cc724f3-- | ||
--=_9b038d50a3b2b5cfe9fdbd53743b1ea9-- |