Skip to content
This repository has been archived by the owner on Dec 6, 2024. It is now read-only.

Commit

Permalink
Merge pull request #141 from open-qhm/fix-encode-mime-header
Browse files Browse the repository at this point in the history
メールにファイル名が日本語のファイルを添付すると文字化けする問題を修正
  • Loading branch information
big2men authored Jun 14, 2021
2 parents 749ec6c + 96e21ba commit 815bb1b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// PukiWiki version / Copyright / Licence

define('S_VERSION', '1.4.7');
define('QHM_VERSION', '7.3.7'); //絶対に編集しないで下さい
define('QHM_VERSION', '7.3.8'); //絶対に編集しないで下さい
define('QHM_OPTIONS', 'update=download; support=false; banner=true');
define('S_COPYRIGHT',
'powered by <strong><a href="https://haik-cms.jp/">HAIK</a> ' . QHM_VERSION . '</strong><br />' .
Expand Down
13 changes: 12 additions & 1 deletion lib/simplemail.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ function send($body){
}

$body = str_replace("\r", "", $body);
$body = $this->normalize($body);
$body = mb_convert_kana($body, "KV");
$body = mb_convert_encoding($body, $mail_encode, $this->encoding);

Expand Down Expand Up @@ -362,13 +363,23 @@ function mkreplace($user) {
return $ret;
}

// 濁点付きの文字が2文字扱いにならないよう合成する
function normalize($str) {
if (class_exists('Normalizer')) {
$str = Normalizer::normalize($str, Normalizer::FORM_C);
}
return $str;
}

/**
* 内部エンコードを変えて、mb_encode_mimeheader() をかける
* 長い差し出し人名などに対応(長すぎると消える)
*/
function mime($str = '', $mail_encode = 'ISO-2022-JP') {
mb_internal_encoding($mail_encode);
$str = mb_encode_mimeheader($str, $mail_encode, $this->encoding);
$str = $this->normalize($str);
$str = mb_convert_encoding($str, $mail_encode, $this->encoding);
$str = mb_encode_mimeheader($str, $mail_encode, 'B');
mb_internal_encoding($this->encoding);

return $str;
Expand Down

0 comments on commit 815bb1b

Please sign in to comment.