diff -ruNp squirrelmail-1.4.6.org/functions/mime.php squirrelmail-1.4.6/functions/mime.php --- squirrelmail-1.4.6.org/functions/mime.php 2006-08-15 13:10:40.000000000 +0900 +++ squirrelmail-1.4.6/functions/mime.php 2006-08-15 15:39:53.000000000 +0900 @@ -249,6 +249,7 @@ function translateText(&$body, $wrap_at, require_once(SM_PATH . 'functions/url_parser.php'); + $charset = strtolower($charset); $body_ary = explode("\n", $body); for ($i=0; $i < count($body_ary); $i++) { $line = $body_ary[$i]; @@ -312,6 +313,14 @@ function formatBody($imap_stream, $messa } $body = ''; + if (!$charset_converted) { + if ($charset == 'iso-2022-jp' || $charset == 'shift_jis' || $charset == 'euc-jp' || + ($squirrelmail_language == 'ja_JP' && + ($charset == 'utf-8' || $charset == '' || $charset == 'us-ascii'))) { + $body = $languages['ja_JP']['XTRA_CODE']('decode', $body); + $charset_converted = true; + } + } $urlmailbox = urlencode($mailbox); $body_message = getEntity($message, $ent_num); if (($body_message->header->type0 == 'text') || @@ -319,12 +328,15 @@ function formatBody($imap_stream, $messa $body = mime_fetch_body ($imap_stream, $id, $ent_num); $body = decodeBody($body, $body_message->header->encoding); - if (isset($languages[$squirrelmail_language]['XTRA_CODE']) && - function_exists($languages[$squirrelmail_language]['XTRA_CODE'])) { - if (mb_detect_encoding($body) != 'ASCII') { - $body = $languages[$squirrelmail_language]['XTRA_CODE']('decode', $body); - } + $charset_converted = false; + if (strtolower($body_message->header->getParameter('charset')) == 'iso-2022-jp' && + isset($languages[$squirrelmail_language]['XTRA_CODE']) && + function_exists($languages[$squirrelmail_language]['XTRA_CODE'])) { + if (mb_detect_encoding($body) != 'ASCII') { + $body = $languages[$squirrelmail_language]['XTRA_CODE']('decode', $body); + } } + $hookResults = do_hook("message_body", $body); $body = $hookResults[1]; @@ -584,6 +596,13 @@ function decodeBody($body, $encoding) { * str_replace("\r\n", "\n", $body); call. */ $body = quoted_printable_decode($body); + + if ($squirrelmail_language != 'ja_JP') { + while (ereg("=n", $body)) { + $body = ereg_replace ("=n", '', $body); + } + } + } elseif ($encoding == 'base64') { $body = base64_decode($body); } @@ -2142,13 +2161,14 @@ function SendDownloadHeaders($type0, $ty $isIE6plus = true; } - if (isset($languages[$squirrelmail_language]['XTRA_CODE']) && - function_exists($languages[$squirrelmail_language]['XTRA_CODE'])) { - $filename = - $languages[$squirrelmail_language]['XTRA_CODE']('downloadfilename', $filename, $HTTP_USER_AGENT); - } else { - $filename = ereg_replace('[\\/:\*\?"<>\|;]', '_', str_replace(' ', ' ', $filename)); - } + if($squirrelmail_language != 'ja_JP') + if (isset($languages[$squirrelmail_language]['XTRA_CODE']) && + function_exists($languages[$squirrelmail_language]['XTRA_CODE'])) { + $filename = + $languages[$squirrelmail_language]['XTRA_CODE']('downloadfilename', $filename, $HTTP_USER_AGENT); + } else { + $filename = ereg_replace('[\\/:\*\?"<>\|;]', '_', str_replace(' ', ' ', $filename)); + } // A Pox on Microsoft and it's Internet Explorer! // @@ -2163,7 +2183,10 @@ function SendDownloadHeaders($type0, $ty // version //set all the Cache Control Headers for IE if ($isIE) { - $filename=rawurlencode($filename); + if($squirrelmail_language != 'ja_JP') + $filename=rawurlencode($filename); + else + $filename = mb_convert_encoding($filename,"SJIS"); header ("Pragma: public"); header ("Cache-Control: no-store, max-age=0, no-cache, must-revalidate"); // HTTP/1.1 header ("Cache-Control: post-check=0, pre-check=0", false);