Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kodus mail error in quoted printable encode native php function #20

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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