roundcubemail-0.3.1-ja3.patch [ダウンロード]

diff -Nur roundcubemail-0.3.1/config/main.inc.php.dist roundcubemail-0.3.1-ja3/config/main.inc.php.dist
--- roundcubemail-0.3.1/config/main.inc.php.dist	2009-10-21 17:47:40.000000000 +0900
+++ roundcubemail-0.3.1-ja3/config/main.inc.php.dist	2009-11-01 12:46:39.000000000 +0900
@@ -217,6 +217,15 @@
 // Use this charset as fallback for message decoding
 $rcmail_config['default_charset'] = 'ISO-8859-1';
 
+// Use this message charset as compose message
+// Configure as a PHP style hash array: array('ja_JP' => 'ISO-2022-JP');
+$rcmail_config['message_charset_languages'] = array('en_US' => 'ISO-8859-1', 'ISO-8859-1' => 'ASCII', 'ko_KR' => 'EUC-KR', 'zh_TW' => 'BIG5', 'zh_CN' => 'GB2312', 'ja_JP' => 'ISO-2022-JP');
+
+// Use this message transfer encoding as compose message
+// Configure as a PHP style hash array: array('ja_JP' => 'base64');
+// transfer_encoding is 'base64' or 'quoted-printable'
+$rcmail_config['transfer_encoding_languages'] = array('en_US' => 'quoted-printable', 'en_GB' => 'quoted-printable', 'ko_KR' => 'base64', 'zh_TW' => 'base64', 'zh_CN' => 'base64', 'ja_JP' => 'base64');
+
 // Make use of the built-in spell checker. It is based on GoogieSpell.
 // Since Google only accepts connections over https your PHP installatation
 // requires to be compiled with Open SSL support
diff -Nur roundcubemail-0.3.1/installer/rcube_install.php roundcubemail-0.3.1-ja3/installer/rcube_install.php
--- roundcubemail-0.3.1/installer/rcube_install.php	2009-08-27 22:38:26.000000000 +0900
+++ roundcubemail-0.3.1-ja3/installer/rcube_install.php	2009-11-01 12:46:39.000000000 +0900
@@ -188,6 +188,18 @@
 	  if (!in_array($_folder, $value))  $value[] = $_folder;
         }
       }
+      else if ($prop == 'default_imap_folders'){
+	$value = Array();
+	foreach($this->config['default_imap_folders'] as $_folders){
+	  switch($_folders){
+	  case 'Drafts': $_folders = $this->config['drafts_mbox']; break;
+	  case 'Sent':   $_folders = $this->config['sent_mbox']; break;
+	  case 'Junk':   $_folders = $this->config['junk_mbox']; break;
+	  case 'Trash':  $_folders = $this->config['trash_mbox']; break;
+          }
+	  if (!in_array($_folders, $value))  $value[] = $_folders;
+        }
+      }
       else if (is_bool($default)) {
         $value = (bool)$value;
       }
diff -Nur roundcubemail-0.3.1/program/include/main.inc roundcubemail-0.3.1-ja3/program/include/main.inc
--- roundcubemail-0.3.1/program/include/main.inc	2009-10-27 18:43:39.000000000 +0900
+++ roundcubemail-0.3.1-ja3/program/include/main.inc	2010-05-14 15:08:29.000000000 +0900
@@ -193,20 +193,17 @@
   if ($from == $to || empty($str) || empty($from))
     return $str;
 
-  // convert charset using iconv module  
-  if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7') {
-    $_iconv = iconv($from, $to . '//IGNORE', $str);
-    if ($_iconv !== false) {
-        return $_iconv;
-    }
-  }
-
   if (is_null($mbstring_loaded))
     $mbstring_loaded = extension_loaded('mbstring');
     
   // convert charset using mbstring module
   if ($mbstring_loaded) {
-    $aliases['WINDOWS-1257'] = 'ISO-8859-13';
+    $aliases['WINDOWS-1257']	= 'ISO-8859-13';
+    $aliases['JIS']		= 'ISO-2022-JP-MS';
+    $aliases['ISO-2022-JP']	= 'ISO-2022-JP-MS';
+    $aliases['EUC-JP']		= 'EUCJP-WIN';
+    $aliases['SJIS']		= 'SJIS-WIN';
+    $aliases['SHIFT_JIS']	= 'SJIS-WIN';
     
     if (is_null($mbstring_list)) {
       $mbstring_list = mb_list_encodings();
@@ -223,6 +220,14 @@
     }
   }
 
+  // convert charset using iconv module  
+  if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7') {
+    $_iconv = iconv($from, $to . '//IGNORE', $str);
+    if ($_iconv !== false) {
+        return $_iconv;
+    }
+  }
+
   // convert charset using bundled classes/functions
   if ($to == 'UTF-8') {
     if ($from == 'UTF7-IMAP') {
diff -Nur roundcubemail-0.3.1/program/include/rcube_imap.php roundcubemail-0.3.1-ja3/program/include/rcube_imap.php
--- roundcubemail-0.3.1/program/include/rcube_imap.php	2009-10-19 16:47:10.000000000 +0900
+++ roundcubemail-0.3.1-ja3/program/include/rcube_imap.php	2009-11-18 11:41:51.000000000 +0900
@@ -1549,9 +1549,9 @@
 
     // convert charset (if text or message part)
     if ($o_part->ctype_primary=='text' || $o_part->ctype_primary=='message') {
-      // assume default if no charset specified
+      // detect encoding if no charset specified
       if (empty($o_part->charset) || strtolower($o_part->charset) == 'us-ascii')
-        $o_part->charset = $this->default_charset;
+        $o_part->charset = rc_detect_encoding($body, $this->default_charset);
 
       $body = rcube_charset_convert($body, $o_part->charset);
       }
@@ -2715,7 +2715,12 @@
       // Loop through the string to decode all occurences of =? ?= into the variable $out 
       while(($pos = strpos($input, '=?')) !== false) {
         // Append everything that is before the text to be decoded
-        $out .= substr($input, 0, $pos);
+	$_before = substr($input, 0, $pos);
+	$_enc = rc_detect_encoding($_before, "ASCII");
+	if ($_enc != "ASCII"){
+		$_before = rcube_charset_convert($_before, $_enc);
+	}
+	$out .= $_before;
 
         // Get the location of the text to decode
         $end_cs_pos = strpos($input, "?", $pos+2);
diff -Nur roundcubemail-0.3.1/program/include/rcube_message.php roundcubemail-0.3.1-ja3/program/include/rcube_message.php
--- roundcubemail-0.3.1/program/include/rcube_message.php	2009-10-25 02:04:22.000000000 +0900
+++ roundcubemail-0.3.1-ja3/program/include/rcube_message.php	2009-11-01 12:46:39.000000000 +0900
@@ -67,6 +67,11 @@
     $this->uid = $uid;
     $this->headers = $this->imap->get_headers($uid, NULL, true, true);
 
+    $_encoding = "";
+    if (empty($this->headers->charset)){
+      $_encoding = rc_detect_encoding($this->headers->subject, "ASCII");
+      if ($_encoding != "ASCII")  $this->headers->charset = $_encoding;
+    }
     $this->subject = rcube_imap::decode_mime_string($this->headers->subject, $this->headers->charset);
     list(, $this->sender) = each($this->imap->decode_address_list($this->headers->from));
     
diff -Nur roundcubemail-0.3.1/program/include/rcube_shared.inc roundcubemail-0.3.1-ja3/program/include/rcube_shared.inc
--- roundcubemail-0.3.1/program/include/rcube_shared.inc	2009-10-27 18:43:39.000000000 +0900
+++ roundcubemail-0.3.1-ja3/program/include/rcube_shared.inc	2009-11-01 12:46:39.000000000 +0900
@@ -568,18 +568,57 @@
         return $failover;
     }
 
-    // FIXME: the order is important, because sometimes 
-    // iso string is detected as euc-jp and etc.
-    $enc = array(
-      'UTF-8', 'SJIS', 'BIG5', 'GB2312',
-      'ISO-8859-1', 'ISO-8859-2', 'ISO-8859-3', 'ISO-8859-4',
-      'ISO-8859-5', 'ISO-8859-6', 'ISO-8859-7', 'ISO-8859-8', 'ISO-8859-9',
-      'ISO-8859-10', 'ISO-8859-13', 'ISO-8859-14', 'ISO-8859-15', 'ISO-8859-16',
-      'WINDOWS-1252', 'WINDOWS-1251', 'EUC-JP', 'EUC-TW', 'KOI8-R', 
-      'ISO-2022-KR', 'ISO-2022-JP'
-    );
+    switch ($_SESSION['language']){
+    case 'ja_JP': // for Japanese
+	$enc = array(
+	    'ASCII', 'ISO-2022-JP', 'JIS',
+	    'UTF-8', 
+	    'EUC-JP', 'eucJP-win', 'SJIS', 'SJIS-win',
+	);
+        break;
+
+    case 'zh_CN': // for Chinese (Simplified)
+    case 'zh_TW': // for Chinese (Traditional)',
+
+	$enc = array(
+	    'ASCII',
+	    'UTF-8', 
+	    'BIG5', 'GB2312', 'EUC-TW',
+	);
+        break;
+
+    case  'ko_KR': // for Korean
+	$enc = array(
+	    'ASCII',
+	    'UTF-8', 
+	    'EUC-KR', 'ISO-2022-KR',
+	);
+        break;
+
+    case 'ru_RU': // for Russian
+	$enc = array(
+	    'ASCII',
+	    'UTF-8', 
+	    'WINDOWS-1251', 'KOI8-R',
+	);
+        break;
+
+    default:
+	$enc = array(
+	    'ASCII',
+	    'UTF-8',
+	    'WINDOWS-1252', 
+	);
+        break;
+    }
 
     $result = mb_detect_encoding($string, join(',', $enc));
+    switch(strtoupper($result)) {
+    	case 'JIS'      : $result = "ISO-2022-JP"; break;
+    	case 'EUCJP-WIN': $result = "EUC-JP";      break;
+    	case 'SJIS' :
+    	case 'SJIS-WIN' : $result = "Shift_JIS";   break;
+    }
 
     return $result ? $result : $failover;
 }
diff -Nur roundcubemail-0.3.1/program/lib/Mail/mimePart.php roundcubemail-0.3.1-ja3/program/lib/Mail/mimePart.php
--- roundcubemail-0.3.1/program/lib/Mail/mimePart.php	2009-06-20 15:55:17.000000000 +0900
+++ roundcubemail-0.3.1-ja3/program/lib/Mail/mimePart.php	2009-11-01 12:46:40.000000000 +0900
@@ -185,7 +185,7 @@
 	
         if (isset($contentType['type'])) {
             $headers['Content-Type'] = $contentType['type'];
-	    if (isset($contentType['charset'])) {
+	    if (isset($contentType['charset']) && !preg_match("|charset|i", $contentType['type'])) {
                 $headers['Content-Type'] .= "; charset={$contentType['charset']}";
             }
             if (isset($contentType['name'])) {
@@ -417,7 +417,7 @@
 
 	// RFC2231:
         $encValue = preg_replace('#([^\x21,\x23,\x24,\x26,\x2B,\x2D,\x2E,\x30-\x39,\x41-\x5A,\x5E-\x7E])#e',
-			'"%" . strtoupper(dechex(ord("\1")))', $value);
+			'"%" . __dechex_ord("\1")', $value);
         $value = "$charset'$language'$encValue";
 
         $header = " {$name}*={$value};";
@@ -475,6 +475,11 @@
 		$quoted .= $ext;
 	    }
 	}
+        else if (function_exists("mb_encode_mimeheader")){
+            mb_internal_encoding($charset);
+            $quoted = mb_encode_mimeheader($value, $charset, ($encoding == 'base64' ? 'B' : 'Q'), MAIL_MIMEPART_CRLF);
+            mb_internal_encoding(RCMAIL_CHARSET);
+        }
 	else if ($encoding == 'base64')
 	{
 	    $ext = strrchr($value, '.');
@@ -506,9 +511,9 @@
 	    // Replace all extended characters (\x80-xFF) with their
 	    // ASCII values.
 	    $ext = preg_replace('/([\x80-\xFF])/e', 
-		'"=" . strtoupper(dechex(ord("\1")))', $ext);
+		'"=" . __dechex_ord("\1")', $ext);
 	    $value = preg_replace('/([\x80-\xFF])/e', 
-		'"=" . strtoupper(dechex(ord("\1")))', $value);
+		'"=" . __dechex_ord("\1")', $value);
 
             $prefix = '=?' . $charset . '?Q?';
             $suffix = '?=';
@@ -527,3 +532,9 @@
     }
 
 } // End of class
+
+// helper function
+function __dechex_ord( $c ){
+    return strtoupper(dechex(ord(stripslashes( $c ))));
+}
+
diff -Nur roundcubemail-0.3.1/program/lib/Mail/mime.php roundcubemail-0.3.1-ja3/program/lib/Mail/mime.php
--- roundcubemail-0.3.1/program/lib/Mail/mime.php	2008-10-25 09:01:45.000000000 +0900
+++ roundcubemail-0.3.1-ja3/program/lib/Mail/mime.php	2009-11-01 12:46:40.000000000 +0900
@@ -358,6 +358,12 @@
         if (PEAR::isError($filedata)) {
             return $filedata;
         }
+        if (preg_match("|^text/plain|i", $c_type) && !preg_match("|charset|i", $c_type)){
+            $_e = rc_detect_encoding($filedata, "");
+            if (!empty($_e)){
+                $c_type = "text/plain; charset=${_e}";
+            }
+        }
 
         $this->_parts[] = array(
                                 'body'        => $filedata,
diff -Nur roundcubemail-0.3.1/program/localization/ja_JP/labels.inc roundcubemail-0.3.1-ja3/program/localization/ja_JP/labels.inc
--- roundcubemail-0.3.1/program/localization/ja_JP/labels.inc	2009-09-14 01:42:56.000000000 +0900
+++ roundcubemail-0.3.1-ja3/program/localization/ja_JP/labels.inc	2009-11-18 14:28:30.000000000 +0900
@@ -14,7 +14,7 @@
 |         Takashi Takamatsu                          |
 +-----------------------------------------------------------------------+
 
-@version $Id: labels.inc 2953 2009-09-13 16:42:56Z yllar $
+@version $Id: labels.inc 3101 2009-11-05 21:35:06Z yllar $
 
 */
 
@@ -160,12 +160,12 @@
 $labels['highest'] = '最高';
 $labels['nosubject'] = '(件名なし)';
 $labels['showimages'] = '画像の表示';
-$labels['alwaysshow'] = '$sender の画像は常に表示する';
+$labels['alwaysshow'] = '$sender から届いた画像は常に表示';
 $labels['htmltoggle'] = 'HTML';
 $labels['plaintoggle'] = 'テキスト';
 $labels['savesentmessagein'] = '送信済みメールの保存先';
 $labels['dontsave'] = '保存しない';
-$labels['maxuploadsize'] = '添付可能ファイルサイズ : $size';
+$labels['maxuploadsize'] = '添付可能なファイルサイズは最大 $size です。';
 $labels['addcc'] = 'Cc 追加';
 $labels['addbcc'] = 'Bcc 追加';
 $labels['addreplyto'] = 'Reply-To 追加';
@@ -215,11 +215,11 @@
 $labels['autodetect'] = '自動識別';
 $labels['language'] = '言語';
 $labels['timezone'] = 'タイムゾーン';
-$labels['pagesize'] = 'ページ単位の表示件数';
+$labels['pagesize'] = '1ページの表示件数';
 $labels['signature'] = '署名';
-$labels['dstactive'] = '夏時間の適用';
-$labels['htmleditor'] = 'メール作成はHTMLが標準';
-$labels['htmlsignature'] = 'HTML の署名';
+$labels['dstactive'] = 'サマータイムの適用';
+$labels['htmleditor'] = '新規メールではHTMLを標準にする';
+$labels['htmlsignature'] = '署名にHTMLタグを使用';
 $labels['previewpane'] = 'プレビューペインの表示';
 $labels['skin'] = 'スキン';
 $labels['logoutclear'] = 'ログアウト時にごみ箱を空にする';
@@ -247,16 +247,29 @@
 $labels['mimeparamfolding'] = '添付ファイル名';
 $labels['2231folding'] = 'RFC 2231 準拠 (Thunderbird)';
 $labels['miscfolding'] = 'RFC 2047/2231 (MS Outlook)';
-$labels['2047folding'] = 'RFC 2047 準拠 (other)';
+$labels['2047folding'] = 'RFC 2047 準拠 (他のメーラー)';
 $labels['advancedoptions'] = '高度な設定';
-$labels['focusonnewmessage'] = '新着メールが届いたらブラウザにフォーカスを移す';
-$labels['checkallfolders'] = 'すべてのフォルダで新着メールを確認する';
-$labels['displaynext'] = 'メールを削除・移動したら、次のメールを表示する';
+$labels['focusonnewmessage'] = '新着メールが届いたらブラウザをアクティブ化';
+$labels['checkallfolders'] = 'すべてのフォルダで新着メールを表示';
+$labels['displaynext'] = 'メールの削除・移動後に次のメールを表示';
+$labels['indexsort'] = '日付での整列にメッセージインデックスを使用';
 $labels['mainoptions'] = '基本設定';
 $labels['section'] = '設定項目';
 $labels['maintenance'] = 'メンテナンス設定';
 $labels['newmessage'] = '新着メール設定';
 $labels['listoptions'] = '一覧設定';
+$labels['signatureoptions'] = '署名の設定';
+$labels['whenreplying'] = '返信時の本文';
+$labels['replytopposting'] = 'オリジナル引用部の前に本文を作成';
+$labels['replybottomposting'] = 'オリジナル引用部の後に本文を作成';
+$labels['replyremovesignature'] = '返信時にメッセージからオリジナルの署名を除去';
+$labels['autoaddsignature'] = '署名を自動的に付加';
+$labels['newmessageonly'] = '新規作成時のみ';
+$labels['replyandforwardonly'] = '返信・転送時のみ';
+$labels['replysignaturepos'] = '返信・転送時に署名を挿入する位置';
+$labels['belowquote'] = '引用部の後';
+$labels['abovequote'] = '引用部の前';
+$labels['insertsignature'] = '署名の挿入';
 $labels['folder'] = 'フォルダ';
 $labels['folders'] = 'フォルダ一覧';
 $labels['foldername'] = 'フォルダ名';
@@ -269,7 +282,7 @@
 $labels['deletefolder'] = 'フォルダの削除';
 $labels['managefolders'] = 'フォルダの管理';
 $labels['specialfolders'] = '特殊なフォルダ';
-$labels['sortby'] = '整列の基準にする';
+$labels['sortby'] = '整列の基準';
 $labels['sortasc'] = '昇順で整列';
 $labels['sortdesc'] = '降順で整列';
 $labels['B'] = 'バイト';
diff -Nur roundcubemail-0.3.1/program/localization/ja_JP/messages.inc roundcubemail-0.3.1-ja3/program/localization/ja_JP/messages.inc
--- roundcubemail-0.3.1/program/localization/ja_JP/messages.inc	2009-09-14 01:42:56.000000000 +0900
+++ roundcubemail-0.3.1-ja3/program/localization/ja_JP/messages.inc	2009-11-18 14:27:13.000000000 +0900
@@ -14,7 +14,7 @@
 |         Takashi Takamatsu                          |
 +-----------------------------------------------------------------------+
 
-@version $Id: messages.inc 2953 2009-09-13 16:42:56Z yllar $
+@version $Id: messages.inc 3086 2009-11-02 08:10:53Z yllar $
 
 */
 
@@ -24,11 +24,12 @@
 $messages['sessionerror'] = 'セッションが正しくないか期限切れです。';
 $messages['imaperror'] = 'IMAP サーバへの接続に失敗しました。';
 $messages['servererror'] = 'サーバエラーが発生しました。';
-$messages['invalidrequest'] = '不正なリクエストです! 保存されませんでした。';
+$messages['invalidrequest'] = '不正なリクエストです。データは保存されませんでした。';
 $messages['nomessagesfound'] = 'メールはありません。';
 $messages['loggedout'] = 'ログアウトしました。';
 $messages['mailboxempty'] = 'メールボックスは空です。';
 $messages['loading'] = '読込中...';
+$messages['uploading'] = 'アップロード中...';
 $messages['loadingdata'] = 'データを読込中...';
 $messages['checkingmail'] = 'メールを確認しています...';
 $messages['sendingmessage'] = 'メールを送信しています...';
@@ -37,13 +38,13 @@
 $messages['messagesaved'] = 'メールを下書きに保存しました。';
 $messages['successfullysaved'] = '保存しました。';
 $messages['addedsuccessfully'] = 'アドレス帳への連絡先の追加しました。';
-$messages['contactexists'] = 'このメールアドレスは既にアドレス帳に存在します。';
+$messages['contactexists'] = 'このメールアドレスを含む連絡先が既に存在します。';
 $messages['blockedimages'] = 'プライバシー保護のため、このメールに含まれるリモート画像をブロックしました。';
 $messages['encryptedmessage'] = 'このメールは暗号化されているため表示できません。';
 $messages['nocontactsfound'] = '連絡先がありません。';
 $messages['contactnotfound'] = '要求された連絡先が見つかりません。';
 $messages['sendingfailed'] = 'メール送信に失敗しました。';
-$messages['senttooquickly'] = 'このメールを送信するまで $sec 秒お待ちください。';
+$messages['senttooquickly'] = 'このメールを送信するまで $sec 秒 お待ちください。';
 $messages['errorsavingsent'] = '送信メールの保存中にエラーが発生しました。';
 $messages['errorsaving'] = '保存中にエラーが発生しました。';
 $messages['errormoving'] = 'メールを移動できません。';
@@ -69,8 +70,9 @@
 $messages['noldapserver'] = '検索する LDAP サーバーを選択して下さい。';
 $messages['nocontactsreturned'] = '連絡先がありません。';
 $messages['nosearchname'] = '連絡先の名前かメールアドレスを入力して下さい。';
+$messages['notuploadedwarning'] = 'アップロードが完了していません。アップロードが完了するまで待つか、キャンセルして下さい。';
 $messages['searchsuccessful'] = ' $nr 件のメールが見つかりました。';
-$messages['searchnomatch'] = '一致するメールはありません。';
+$messages['searchnomatch'] = '一致するメールがありません。';
 $messages['searching'] = '検索中...';
 $messages['checking'] = '確認中...';
 $messages['nospellerrors'] = 'スペルミスは見つかりませんでした。';
@@ -79,7 +81,7 @@
 $messages['converting'] = 'メールから書式を削除しています...';
 $messages['messageopenerror'] = 'サーバからメールを取得できません。';
 $messages['fileuploaderror'] = 'ファイルのアップロードに失敗しました。';
-$messages['filesizeerror'] = 'アップロードファイルのサイズが上限 $size を超えました。';
+$messages['filesizeerror'] = 'アップロードするファイルのサイズが上限 $size を超えました。';
 $messages['copysuccess'] = 'アドレス $nr 個のコピーに成功しました。';
 $messages['copyerror'] = 'アドレスをコピーできません。';
 $messages['sourceisreadonly'] = 'このアドレス情報は読取専用です。';
@@ -87,7 +89,7 @@
 $messages['movingmessage'] = 'メールを移動しています...';
 $messages['receiptsent'] = '開封確認を送信しました。';
 $messages['errorsendingreceipt'] = '開封確認を送信できません。';
-$messages['nodeletelastidentity'] = '削除できません。少なくとも1つの個人情報が必要です。';
+$messages['nodeletelastidentity'] = '削除できません。少なくとも1つの個人情報が必要です。';
 $messages['addsubfolderhint'] = '現在選択しているフォルダのサブフォルダとして作成されます。';
 $messages['forbiddencharacter'] = 'フォルダ名に利用できない文字が含まれています。';
 $messages['selectimportfile'] = 'アップロードするファイルを選択してください。';
@@ -95,15 +97,16 @@
 $messages['importwait'] = 'インポート中です。しばらくお待ちください...';
 $messages['importerror'] = 'インポートに失敗しました。アップロードしたファイルは不正な vCard ファイルです。';
 $messages['importconfirm'] = '$inserted 件の連絡先をインポートしました。
既登録の連絡先 $skipped 件をスキップしました

$names

'; -$messages['opnotpermitted'] = 'その操作は許可されていません。'; +$messages['opnotpermitted'] = '許可されていない操作です。'; $messages['nofromaddress'] = '選択中の個人情報にメールアドレスが含まれていません。'; $messages['editorwarning'] = 'テキストエディタに切り替えるとすべての書式が失われます。よろしいですか?'; $messages['httpreceivedencrypterror'] = '致命的な設定エラーが発生しました。メッセージは送信されませんでした。システム管理者に至急連絡してください。'; -$messages['smtpconnerror'] = 'SMTP Error ($code): サーバーへの接続に失敗しました'; -$messages['smtpautherror'] = 'SMTP Error ($code): 認証に失敗しました'; -$messages['smtpfromerror'] = 'SMTP Error ($code): 差出人 "$from" を設定できませんでした'; -$messages['smtptoerror'] = 'SMTP Error ($code): 宛先 "$to" を追加できませんでした'; -$messages['smtprecipientserror'] = 'SMTP Error: 宛先のリストを解析できませんでした'; +$messages['smtpconnerror'] = 'SMTP Error ($code): サーバーへの接続に失敗'; +$messages['smtpautherror'] = 'SMTP Error ($code): 認証に失敗'; +$messages['smtpfromerror'] = 'SMTP Error ($code): 差出人 "$from" を設定できません'; +$messages['smtptoerror'] = 'SMTP Error ($code): 宛先 "$to" を追加できません'; +$messages['smtprecipientserror'] = 'SMTP Error: 宛先のリストを解析できません'; $messages['smtperror'] = 'SMTP Error: $msg'; +$messages['emailformaterror'] = '不正確なメールアドレスです: $email'; ?> diff -Nur roundcubemail-0.3.1/program/steps/mail/attachments.inc roundcubemail-0.3.1-ja3/program/steps/mail/attachments.inc --- roundcubemail-0.3.1/program/steps/mail/attachments.inc 2009-10-06 15:55:08.000000000 +0900 +++ roundcubemail-0.3.1-ja3/program/steps/mail/attachments.inc 2010-08-11 11:47:35.000000000 +0900 @@ -78,9 +78,11 @@ if (is_array($_FILES['_attachments']['tmp_name'])) { foreach ($_FILES['_attachments']['tmp_name'] as $i => $filepath) { + $_name = $_FILES['_attachments']['name'][$i]; + $_name = rcube_charset_convert($_name, RCMAIL_CHARSET, rc_detect_encoding($_name, RCMAIL_CHARSET)); $attachment = array( 'path' => $filepath, - 'name' => $_FILES['_attachments']['name'][$i], + 'name' => $_name, 'mimetype' => rc_mime_content_type($filepath, $_FILES['_attachments']['name'][$i], $_FILES['_attachments']['type'][$i]) ); diff -Nur roundcubemail-0.3.1/program/steps/mail/func.inc roundcubemail-0.3.1-ja3/program/steps/mail/func.inc --- roundcubemail-0.3.1/program/steps/mail/func.inc 2009-10-25 04:09:23.000000000 +0900 +++ roundcubemail-0.3.1-ja3/program/steps/mail/func.inc 2009-11-01 12:46:59.000000000 +0900 @@ -422,6 +422,10 @@ if (empty($header)) continue; + if (empty($header->charset)){ + $_encoding = rc_detect_encoding($header->subject, "ASCII"); + if ($_encoding != "ASCII") $header->charset = $_encoding; + } $IMAP->set_charset(!empty($header->charset) ? $header->charset : $CONFIG['default_charset']); // format each col; similar as in rcmail_message_list() diff -Nur roundcubemail-0.3.1/program/steps/mail/get.inc roundcubemail-0.3.1-ja3/program/steps/mail/get.inc --- roundcubemail-0.3.1/program/steps/mail/get.inc 2009-09-22 16:50:32.000000000 +0900 +++ roundcubemail-0.3.1-ja3/program/steps/mail/get.inc 2009-11-01 12:46:59.000000000 +0900 @@ -75,6 +75,12 @@ header("Content-Type: application/force-download"); } else if ($ctype_primary == 'text') { + if (empty($part->charset)){ + // get part body if not available and detect part charset + if (!$part->body) + $part->body = $MESSAGE->get_part_content($part->mime_id); + } + header("Content-Type: text/$ctype_secondary; charset=" . ($part->charset ? $part->charset : RCMAIL_CHARSET)); } else { @@ -109,7 +115,7 @@ header("Content-Disposition: $disposition; filename=\"$filename\""); // turn off output buffering and print part content - if ($part->body) + if ($part->body && $part->charset == RCMAIL_CHARSET) echo $part->body; else if ($part->size) $IMAP->get_message_part($MESSAGE->uid, $part->mime_id, $part, true); diff -Nur roundcubemail-0.3.1/program/steps/mail/sendmail.inc roundcubemail-0.3.1-ja3/program/steps/mail/sendmail.inc --- roundcubemail-0.3.1/program/steps/mail/sendmail.inc 2009-10-14 19:52:27.000000000 +0900 +++ roundcubemail-0.3.1-ja3/program/steps/mail/sendmail.inc 2010-02-22 14:40:27.000000000 +0900 @@ -149,7 +149,7 @@ } // parse email address input -function rcmail_email_input_format($mailto) +function rcmail_email_input_format($mailto, $message_charset = RCMAIL_CHARSET, $message_transfer_encoding = 'quoted-printable') { global $EMAIL_FORMAT_ERROR; @@ -157,6 +157,7 @@ $replace = array(', ', ', ', '', ',', '\\1 \\2'); // replace new lines and strip ending ', ', make address input more valid + $mailto = rcube_charset_convert($mailto, $message_charset, 'UTF-8'); $mailto = trim(preg_replace($regexp, $replace, $mailto)); $result = array(); @@ -166,10 +167,10 @@ $item = trim($item); // address in brackets without name (do nothing) if (preg_match('/^<\S+@\S+>$/', $item)) { - $result[] = $item; + $result[] = Array('', $item); // address without brackets and without name (add brackets) } else if (preg_match('/^\S+@\S+$/', $item)) { - $result[] = '<'.$item.'>'; + $result[] = Array('', '<'.$item.'>'); // address with name (handle name) } else if (preg_match('/\S+@\S+>*$/', $item, $matches)) { $address = $matches[0]; @@ -182,7 +183,7 @@ if (!preg_match('/^<\S+@\S+>$/', $address)) $address = '<'.$address.'>'; - $result[] = $name.' '.$address; + $result[] = Array($name, $address); $item = $address; } else if (trim($item)) { continue; @@ -196,7 +197,43 @@ } } - return implode(', ', $result); + $mailto = array(); + if (function_exists("mb_encode_mimeheader")) { + mb_internal_encoding('UTF-8'); + foreach($result as $item){ + if (empty($item[0])){ + $mailto[] = $item[1]; + } else { + $mailto[] = mb_encode_mimeheader($item[0], $message_charset, ($message_transfer_encoding == 'base64' ? 'B' : 'Q')) .' '.$item[1]; + } + } + mb_internal_encoding(RCMAIL_CHARSET); + } else { + foreach($result as $item){ + if (empty($item[0])){ + $mailto[] = $item[1]; + } else { + $mailto[] = $item[0].' '.$item[1]; + } + } + } + + return implode(', ', $mailto); +} + +function strip_unknown_charset($ctype){ + if (preg_match('/charset/', $ctype)){ + $ctypes = explode(";", $ctype); + $ctype = ""; + foreach($ctypes as $_s){ + $_s = trim($_s); + if (!empty($_s) && ! preg_match('/^charset=.*unknown/i', $_s)){ + $ctype .= "{$_s}; "; + } + } + } + + return $ctype; } /****** compose message ********/ @@ -208,13 +245,20 @@ // set default charset $input_charset = $OUTPUT->get_charset(); +$message_transfer_encoding = 'quoted-printable'; +if (array_key_exists($_SESSION['language'], $CONFIG['message_charset_languages'])){ + $input_charset = $CONFIG['message_charset_languages'][$_SESSION['language']]; + if (array_key_exists($_SESSION['language'], $CONFIG['transfer_encoding_languages'])){ + $message_transfer_encoding = $CONFIG['transfer_encoding_languages'][$_SESSION['language']]; + } +} $message_charset = isset($_POST['_charset']) ? $_POST['_charset'] : $input_charset; $EMAIL_FORMAT_ERROR = NULL; -$mailto = rcmail_email_input_format(get_input_value('_to', RCUBE_INPUT_POST, TRUE, $message_charset)); -$mailcc = rcmail_email_input_format(get_input_value('_cc', RCUBE_INPUT_POST, TRUE, $message_charset)); -$mailbcc = rcmail_email_input_format(get_input_value('_bcc', RCUBE_INPUT_POST, TRUE, $message_charset)); +$mailto = rcmail_email_input_format(get_input_value('_to', RCUBE_INPUT_POST, TRUE, $message_charset), $message_charset, $message_transfer_encoding); +$mailcc = rcmail_email_input_format(get_input_value('_cc', RCUBE_INPUT_POST, TRUE, $message_charset), $message_charset, $message_transfer_encoding); +$mailbcc = rcmail_email_input_format(get_input_value('_bcc', RCUBE_INPUT_POST, TRUE, $message_charset), $message_charset, $message_transfer_encoding); if ($EMAIL_FORMAT_ERROR) { $OUTPUT->show_message('emailformaterror', 'error', array('email' => $EMAIL_FORMAT_ERROR)); @@ -286,7 +330,7 @@ } $headers['Date'] = date('r'); -$headers['From'] = rcube_charset_convert($identity_arr['string'], RCMAIL_CHARSET, $message_charset); +$headers['From'] = rcmail_email_input_format(rcube_charset_convert($identity_arr['string'], RCMAIL_CHARSET, $message_charset), $message_charset, $message_transfer_encoding); $headers['To'] = $mailto; // additional recipients @@ -306,7 +350,7 @@ $headers['Organization'] = $identity_arr['organization']; if (!empty($_POST['_replyto'])) - $headers['Reply-To'] = rcmail_email_input_format(get_input_value('_replyto', RCUBE_INPUT_POST, TRUE, $message_charset)); + $headers['Reply-To'] = rcmail_email_input_format(get_input_value('_replyto', RCUBE_INPUT_POST, TRUE, $message_charset), $message_charset, $message_transfer_encoding); else if (!empty($identity_arr['reply-to'])) $headers['Reply-To'] = $identity_arr['reply-to']; @@ -416,18 +460,19 @@ } else { $ctype = str_replace('image/pjpeg', 'image/jpeg', $attachment['mimetype']); // #1484914 + $ctype = strip_unknown_charset($ctype); $file = $attachment['data'] ? $attachment['data'] : $attachment['path']; // .eml attachments send inline $MAIL_MIME->addAttachment($file, $ctype, - $attachment['name'], + rcube_charset_convert($attachment['name'], RCMAIL_CHARSET, $message_charset), ($attachment['data'] ? false : true), ($ctype == 'message/rfc822' ? $transfer_encoding : 'base64'), ($ctype == 'message/rfc822' ? 'inline' : 'attachment'), $message_charset, '', '', - $CONFIG['mime_param_folding'] ? 'quoted-printable' : NULL, - $CONFIG['mime_param_folding'] == 2 ? 'quoted-printable' : NULL + $CONFIG['mime_param_folding'] ? $message_transfer_encoding : NULL, + $CONFIG['mime_param_folding'] == 2 ? $message_transfer_encoding : NULL ); } } @@ -438,12 +483,15 @@ foreach ($_FILES['_attachments']['tmp_name'] as $i => $filepath) { $ctype = $files['type'][$i]; $ctype = str_replace('image/pjpeg', 'image/jpeg', $ctype); // #1484914 + $ctype = strip_unknown_charset($ctype); - $MAIL_MIME->addAttachment($filepath, $ctype, $files['name'][$i], true, + $MAIL_MIME->addAttachment($filepath, $ctype, + rcube_charset_convert($files['name'][$i], RCMAIL_CHARSET, $message_charset), true, $ctype == 'message/rfc822' ? $transfer_encoding : 'base64', - 'attachment', $message_charset, '', '', - $CONFIG['mime_param_folding'] ? 'quoted-printable' : NULL, - $CONFIG['mime_param_folding'] == 2 ? 'quoted-printable' : NULL + 'attachment', + $message_charset, '', '', + $CONFIG['mime_param_folding'] ? $message_transfer_encoding : NULL, + $CONFIG['mime_param_folding'] == 2 ? $message_transfer_encoding : NULL ); } } @@ -465,7 +513,7 @@ if (function_exists("mb_encode_mimeheader")) { mb_internal_encoding($message_charset); - $headers['Subject'] = mb_encode_mimeheader($headers['Subject'], $message_charset, 'Q'); + $headers['Subject'] = mb_encode_mimeheader($headers['Subject'], $message_charset, ($message_transfer_encoding == 'base64' ? 'B' : 'Q')); mb_internal_encoding(RCMAIL_CHARSET); }