Skip to content

Commit e59fb22

Browse files
committed
fix headers encoding
1 parent db6d1f2 commit e59fb22

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/Message.php

+10-2
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,9 @@ private function encodeHeader($header, $value)
962962
if (!$coding && $char === 61 && preg_match('/;(\s+)?([a-z0-9\-]+)(\s+)?(=(\s+)?\"[^\"]+)?/ui', $result)) {
963963
$ascii = true;
964964
}
965+
if ($coding && $symbol === ' ') {
966+
$ascii = false;
967+
}
965968
if ($ascii) {
966969
if ($coding) {
967970
$coding = false;
@@ -981,8 +984,13 @@ private function encodeHeader($header, $value)
981984
$add += 3;
982985
}
983986
if ($position + $add >= $max) {
984-
$line = "=\r\n $line";
985-
$position = $add + 1;
987+
if ($coding) {
988+
$line = "?=\r\n =?utf-8?Q?$line";
989+
$position = $add + 11;
990+
} else {
991+
$line = "=\r\n $line";
992+
$position = $add + 1;
993+
}
986994
}
987995
$result .= $line;
988996
$position += $add;

0 commit comments

Comments
 (0)