Skip to content

Commit

Permalink
Merge pull request #20 from kodus/KDS-340-kodus-mail-error-in-quoted_…
Browse files Browse the repository at this point in the history
…printable_encode-native-PHP-function

Kodus mail error in quoted printable encode native php function
  • Loading branch information
jrmoller authored May 6, 2024
2 parents e391f2b + c61bbcd commit f096f26
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/MIMEWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,10 @@ protected function createMultipartBoundaryName(string $prefix): string
*/
protected function escapeHeaderValue(string $value): string
{
$quoted_value = quoted_printable_encode($value);
$quoted_value = str_replace("=\x0d\x0a",'', $quoted_value);
return preg_match('/[\x80-\xFF]/', $value) === 1
? "=?UTF-8?Q?" . quoted_printable_encode($value) . "?="
? "=?UTF-8?Q?" . $quoted_value . "?="
: $value; // as-is
}

Expand Down
2 changes: 1 addition & 1 deletion tests/TestMessageFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public function createMessageWithCustomHeaders(): Message
$message = new Message(
new Address("blip@test.org"),
new Address("blub@test.org"),
"Hey, Rasmus!",
"We need a special character - Ø - so that quoted_printable_encode is used, and more than 75 characters - see documentation for quoted_printable_encode()",
"Hello!"
);

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/MIMEWriterCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ public function writeMessageWithCustomHeaders(UnitTester $I): void
Date: Thu, 15 Sep 2016 17:20:54 +0200
To: blip@test.org
From: blub@test.org
Subject: Hey, Rasmus!
Subject: =?UTF-8?Q?We need a special character - =C3=98 - so that quoted_printable_encode is used, and more than 75 characters - see documentation for quoted_printable_encode()?=
MIME-Version: 1.0
X-Custom-Header: custom-value
Content-Type: text/plain; charset=UTF-8
Expand Down

0 comments on commit f096f26

Please sign in to comment.