Skip to content

Commit

Permalink
fix #1043 受信メールで1行の文字数が多い時、文字化けが発生の改善 (#1256)
Browse files Browse the repository at this point in the history
CakePHP3系では対応済み
cakephp/cakephp@8099090
  • Loading branch information
gondoh authored and ryuring committed Sep 29, 2019
1 parent 494999b commit e92d907
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions lib/Cake/Network/Email/CakeEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -1393,10 +1393,18 @@ protected function _wrap($message, $wrapLength = CakeEmail::LINE_LENGTH_MUST) {
continue;
}
if (!preg_match('/<[a-z]+.*>/i', $line)) {
// >>> CUSTOMIZE MODIFY 2019/09/26 gondoh
// マルチバイトの改行が文字化けする問題の改善
// $formatted = array_merge(
// $formatted,
// explode("\n", wordwrap($line, $wrapLength, "\n", $cut))
// );
// ---
$formatted = array_merge(
$formatted,
explode("\n", wordwrap($line, $wrapLength, "\n", $cut))
explode("\n", CakeText::wordwrap($line, $wrapLength, "\n", $cut))
);
// <<<
continue;
}

Expand All @@ -1414,10 +1422,17 @@ protected function _wrap($message, $wrapLength = CakeEmail::LINE_LENGTH_MUST) {
$tmpLineLength += $tagLength;
} else {
if ($tmpLineLength > 0) {
// >>> CUSTOMIZE MODIFY 2019/09/26 gondoh
// $formatted = array_merge(
// $formatted,
// explode("\n", wordwrap(trim($tmpLine), $wrapLength, "\n", $cut))
// );
// ---
$formatted = array_merge(
$formatted,
explode("\n", wordwrap(trim($tmpLine), $wrapLength, "\n", $cut))
explode("\n", CakeText::wordwrap(trim($tmpLine), $wrapLength, "\n", $cut))
);
// <<<
$tmpLine = '';
$tmpLineLength = 0;
}
Expand Down

0 comments on commit e92d907

Please sign in to comment.