From a58d7b9b639e8b5345b21af86d95a801fe7b5c79 Mon Sep 17 00:00:00 2001 From: Hans Erik Jepsen Date: Wed, 2 Oct 2024 14:37:08 +0200 Subject: [PATCH] Added test with mesage body that breaks if dot stuffing is done before encoding. Changed `Writer::writeFiltered` to use `stream_filter_prepend`. --- src/Writer.php | 2 +- tests/integration/MailServiceCest.php | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/Writer.php b/src/Writer.php index 24ce08e..dc89080 100644 --- a/src/Writer.php +++ b/src/Writer.php @@ -106,7 +106,7 @@ public function writeBase64($input): void */ protected function writeFiltered($input, string $filter, array $options = []): void { - $filter = stream_filter_append($this->output, $filter, STREAM_FILTER_WRITE, $options); + $filter = stream_filter_prepend($this->output, $filter, STREAM_FILTER_WRITE, $options); $this->write($input); diff --git a/tests/integration/MailServiceCest.php b/tests/integration/MailServiceCest.php index ff52c10..a17d9e4 100644 --- a/tests/integration/MailServiceCest.php +++ b/tests/integration/MailServiceCest.php @@ -3,6 +3,8 @@ namespace Kodus\Mail\Test\Integration; use IntegrationTester; +use Kodus\Mail\Address; +use Kodus\Mail\Message; use Kodus\Mail\SMTP\Authenticator\NoAuthenticator; use Kodus\Mail\SMTP\SMTPMailService; use Kodus\Mail\Test\TestMessageFactory; @@ -31,4 +33,29 @@ public function sendMail(IntegrationTester $I) $service->send($message); } } + + public function ensureDotStuffingHappensBeforeQuotePrintableEncode(IntegrationTester $I) + { + $text_body = <<createSocketConnector(), new NoAuthenticator(), "localhost" + ); + + $message = new Message( + new Address("blip@test.org", "Rasmus åh Schultz"), + new Address("blub@test.org"), + "Hey, Rasmus! I like ÆØÅæøå!", + $text_body, + ); + + $message->setDate("Thu, 15 Sep 2016 17:20:54 +0200"); + + $message->setSender(new Address("someone-else@test.org")); + + $service->send($message); + } }