diff --unified --recursive roundcubemail-0.8.1/config/main.inc.php.dist roundcubemail-0.8.1p-ja/config/main.inc.php.dist --- roundcubemail-0.8.1/config/main.inc.php.dist 2012-08-18 04:32:12.000000000 +0900 +++ roundcubemail-0.8.1p-ja/config/main.inc.php.dist 2012-08-27 17:56:52.000000000 +0900 @@ -775,6 +775,9 @@ // When replying place cursor above original message (top posting) $rcmail_config['top_posting'] = false; +// Default charset for sending message +$rcmail_config['send_charset'] = 'ISO-8859-1'; + // When replying strip original signature from message $rcmail_config['strip_existing_sig'] = true; @@ -791,6 +794,9 @@ // Use MIME encoding (quoted-printable) for 8bit characters in message body $rcmail_config['force_7bit'] = false; +// Use MIME B encoding (base64) for header +$rcmail_config['head_encoding_base64'] = false; + // Defaults of the search field configuration. // The array can contain a per-folder list of header fields which should be considered when searching // The entry with key '*' stands for all folders which do not have a specific list set. diff --unified --recursive roundcubemail-0.8.1/program/include/iniset.php roundcubemail-0.8.1p-ja/program/include/iniset.php --- roundcubemail-0.8.1/program/include/iniset.php 2012-08-18 04:32:12.000000000 +0900 +++ roundcubemail-0.8.1p-ja/program/include/iniset.php 2012-08-27 17:57:32.000000000 +0900 @@ -42,7 +42,7 @@ } // application constants -define('RCMAIL_VERSION', '0.8.1'); +define('RCMAIL_VERSION', '0.8.1p-ja'); define('RCMAIL_CHARSET', 'UTF-8'); define('JS_OBJECT_NAME', 'rcmail'); define('RCMAIL_START', microtime(true)); diff --unified --recursive roundcubemail-0.8.1/program/include/rcube_charset.php roundcubemail-0.8.1p-ja/program/include/rcube_charset.php --- roundcubemail-0.8.1/program/include/rcube_charset.php 2012-08-18 04:32:12.000000000 +0900 +++ roundcubemail-0.8.1p-ja/program/include/rcube_charset.php 2012-08-27 19:18:26.000000000 +0900 @@ -189,6 +189,37 @@ return $str; } + // set priority of mbstring higher than iconv + if ($mbstring_loaded === null) { + $mbstring_loaded = extension_loaded('mbstring'); + } + + // convert charset using mbstring module + if ($mbstring_loaded) { + $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 ($mbstring_list === null) { + $mbstring_list = mb_list_encodings(); + $mbstring_list = array_map('strtoupper', $mbstring_list); + } + + $mb_from = $aliases[$from] ? $aliases[$from] : $from; + $mb_to = $aliases[$to] ? $aliases[$to] : $to; + + // return if encoding found, string matches encoding and convert succeeded + if (in_array($mb_from, $mbstring_list) && in_array($mb_to, $mbstring_list)) { + if (mb_check_encoding($str, $mb_from) && ($out = mb_convert_encoding($str, $mb_to, $mb_from))) { + return $out; + } + } + } + // convert charset using iconv module if (function_exists('iconv') && $from != 'UTF7-IMAP' && $to != 'UTF7-IMAP') { if ($iconv_options === null) { @@ -215,30 +246,6 @@ } } - if ($mbstring_loaded === null) { - $mbstring_loaded = extension_loaded('mbstring'); - } - - // convert charset using mbstring module - if ($mbstring_loaded) { - $aliases['WINDOWS-1257'] = 'ISO-8859-13'; - - if ($mbstring_list === null) { - $mbstring_list = mb_list_encodings(); - $mbstring_list = array_map('strtoupper', $mbstring_list); - } - - $mb_from = $aliases[$from] ? $aliases[$from] : $from; - $mb_to = $aliases[$to] ? $aliases[$to] : $to; - - // return if encoding found, string matches encoding and convert succeeded - if (in_array($mb_from, $mbstring_list) && in_array($mb_to, $mbstring_list)) { - if (mb_check_encoding($str, $mb_from) && ($out = mb_convert_encoding($str, $mb_to, $mb_from))) { - return $out; - } - } - } - // convert charset using bundled classes/functions if ($to == 'UTF-8') { if ($from == 'UTF7-IMAP') { diff --unified --recursive roundcubemail-0.8.1/program/include/rcube_mime.php roundcubemail-0.8.1p-ja/program/include/rcube_mime.php --- roundcubemail-0.8.1/program/include/rcube_mime.php 2012-08-18 04:32:12.000000000 +0900 +++ roundcubemail-0.8.1p-ja/program/include/rcube_mime.php 2012-08-27 17:56:52.000000000 +0900 @@ -151,7 +151,7 @@ foreach ($a as $val) { $j++; $address = trim($val['address']); - $name = trim($val['name']); + $name = preg_replace(array('/^[\'"]/','/[\'"]$/'),'', trim($val['name'])); if ($name && $address && $name != $address) $string = sprintf('%s <%s>', preg_match("/$special_chars/", $name) ? '"'.addcslashes($name, '"').'"' : $name, $address); diff --unified --recursive roundcubemail-0.8.1/program/localization/en_US/labels.inc roundcubemail-0.8.1p-ja/program/localization/en_US/labels.inc --- roundcubemail-0.8.1/program/localization/en_US/labels.inc 2012-08-18 04:32:12.000000000 +0900 +++ roundcubemail-0.8.1p-ja/program/localization/en_US/labels.inc 2012-08-27 17:56:52.000000000 +0900 @@ -420,6 +420,7 @@ $labels['miscfolding'] = 'RFC 2047/2231 (MS Outlook)'; $labels['2047folding'] = 'Full RFC 2047 (other)'; $labels['force7bit'] = 'Use MIME encoding for 8-bit characters'; +$labels['encodingbase64'] = 'Use MIME B encoding for header'; $labels['advancedoptions'] = 'Advanced options'; $labels['focusonnewmessage'] = 'Focus browser window on new message'; $labels['checkallfolders'] = 'Check all folders for new messages'; diff --unified --recursive roundcubemail-0.8.1/program/localization/ja_JP/labels.inc roundcubemail-0.8.1p-ja/program/localization/ja_JP/labels.inc --- roundcubemail-0.8.1/program/localization/ja_JP/labels.inc 2012-08-18 04:32:12.000000000 +0900 +++ roundcubemail-0.8.1p-ja/program/localization/ja_JP/labels.inc 2012-08-27 17:56:52.000000000 +0900 @@ -360,6 +360,7 @@ $labels['miscfolding'] = 'RFC 2047/2231(MS Outlook)'; $labels['2047folding'] = 'RFC 2047に完全準拠(その他)'; $labels['force7bit'] = '8ビット文字列にMIMEエンコードを使用'; +$labels['encodingbase64'] = 'ヘッダをMIME Base64エンコードする'; $labels['advancedoptions'] = '高度な設定'; $labels['focusonnewmessage'] = '新しいメッセージが届いたらブラウザーをアクティブ'; $labels['checkallfolders'] = 'すべてのフォルダーで新着メールを表示'; diff --unified --recursive roundcubemail-0.8.1/program/steps/mail/compose.inc roundcubemail-0.8.1p-ja/program/steps/mail/compose.inc --- roundcubemail-0.8.1/program/steps/mail/compose.inc 2012-08-18 04:32:12.000000000 +0900 +++ roundcubemail-0.8.1p-ja/program/steps/mail/compose.inc 2012-08-27 17:56:52.000000000 +0900 @@ -1502,6 +1502,16 @@ } +function rcmail_charset_selector($attrib) +{ + global $RCMAIL; + return $RCMAIL->output->charset_selector(array( + 'name' => '_charset', + 'selected' => $RCMAIL->config->get('send_charset') + )); +} + + function rcmail_check_sent_folder($folder, $create=false) { global $RCMAIL; @@ -1614,6 +1624,7 @@ 'receiptcheckbox' => 'rcmail_receipt_checkbox', 'dsncheckbox' => 'rcmail_dsn_checkbox', 'storetarget' => 'rcmail_store_target_selection', + 'charsetselector' => 'rcmail_charset_selector', 'addressbooks' => 'rcmail_addressbook_list', 'addresslist' => 'rcmail_contacts_list', )); diff --unified --recursive roundcubemail-0.8.1/program/steps/mail/sendmail.inc roundcubemail-0.8.1p-ja/program/steps/mail/sendmail.inc --- roundcubemail-0.8.1/program/steps/mail/sendmail.inc 2012-08-18 04:32:12.000000000 +0900 +++ roundcubemail-0.8.1p-ja/program/steps/mail/sendmail.inc 2012-08-27 17:56:52.000000000 +0900 @@ -78,10 +78,18 @@ global $RCMAIL, $OUTPUT; if ($sql_arr = $RCMAIL->user->get_identity($id)) { + global $message_charset; $out = $sql_arr; $out['mailto'] = $sql_arr['email']; - $out['string'] = format_email_recipient($sql_arr['email'], - rcube_charset_convert($sql_arr['name'], RCMAIL_CHARSET, $OUTPUT->get_charset())); + $name = rcube_charset_convert($sql_arr['name'], RCMAIL_CHARSET, $message_charset); + if (function_exists('mb_encode_mimeheader')) { + global $RCMAIL; + $head_encoding_mode = $RCMAIL->config->get('head_encoding_base64') ? 'B' : 'Q'; + mb_internal_encoding($message_charset); + $name = mb_encode_mimeheader($name, $message_charset, $head_encoding_mode, "\r\n", 8); + mb_internal_encoding(RCMAIL_CHARSET); + } + $out['string'] = format_email_recipient($sql_arr['email'], $name); return $out; } @@ -153,6 +161,12 @@ { global $RCMAIL, $EMAIL_FORMAT_ERROR, $RECIPIENT_COUNT; + // convert UTF-8 to preserve \x2c(,) and \x3b(;) used in ISO-2022-JP; + if (function_exists('mb_encode_mimeheader') + && function_exists('mb_convert_encoding')) { + global $message_charset; + $mailto = mb_convert_encoding($mailto, 'UTF-8', $message_charset); + } // simplified email regexp, supporting quoted local part $email_regexp = '(\S+|("[^"]+"))@\S+'; @@ -183,8 +197,21 @@ if ($name[0] == '"' && $name[count($name)-1] == '"') { $name = substr($name, 1, -1); } - $name = stripcslashes($name); $address = rcube_idn_to_ascii(trim($address, '<>')); + + // encode "name" field. + if (function_exists('mb_encode_mimeheader') + && function_exists('mb_convert_encoding')) { + global $message_charset; + $head_encoding_mode = $RCMAIL->config->get('head_encoding_base64') ? 'B' : 'Q'; + $name = mb_convert_encoding($name, $message_charset, 'UTF-8'); + mb_internal_encoding($message_charset); + $name = preg_replace('/^"(.*)"$/', '$1', $name); + $name = mb_encode_mimeheader($name, $message_charset, $head_encoding_mode, "\r\n", 8); + mb_internal_encoding(RCMAIL_CHARSET); + } else { + $name = stripcslashes($name); + } $result[] = format_email_recipient($address, $name); $item = $address; } else if (trim($item)) { @@ -216,7 +243,10 @@ // set default charset $input_charset = $OUTPUT->get_charset(); -$message_charset = isset($_POST['_charset']) ? $_POST['_charset'] : $input_charset; +$send_charset = $RCMAIL->config->get('send_charset'); +global $message_charset; +$message_charset = isset($_POST['_charset']) ? $_POST['_charset'] : + $send_charset != '' ? $send_charset : $input_charset; $EMAIL_FORMAT_ERROR = NULL; $RECIPIENT_COUNT = 0; @@ -307,7 +337,7 @@ } $headers['Date'] = rcmail_user_date(); -$headers['From'] = rcube_charset_convert($from_string, RCMAIL_CHARSET, $message_charset); +$headers['From'] = $from_string; $headers['To'] = $mailto; // additional recipients @@ -575,19 +605,22 @@ else $transfer_encoding = '7bit'; +$head_encoding = $RCMAIL->config->get('head_encoding_base64') ? 'base64' : 'quoted-printable'; + // encoding settings for mail composing $MAIL_MIME->setParam('text_encoding', $transfer_encoding); $MAIL_MIME->setParam('html_encoding', 'quoted-printable'); -$MAIL_MIME->setParam('head_encoding', 'quoted-printable'); +$MAIL_MIME->setParam('head_encoding', $head_encoding); $MAIL_MIME->setParam('head_charset', $message_charset); $MAIL_MIME->setParam('html_charset', $message_charset); $MAIL_MIME->setParam('text_charset', $message_charset . ($flowed ? ";\r\n format=flowed" : '')); // encoding subject header with mb_encode provides better results with asian characters if (function_exists('mb_encode_mimeheader')) { + $head_encoding_mode = $RCMAIL->config->get('head_encoding_base64') ? 'B' : 'Q'; mb_internal_encoding($message_charset); $headers['Subject'] = mb_encode_mimeheader($headers['Subject'], - $message_charset, 'Q', "\r\n", 8); + $message_charset, $head_encoding_mode, "\r\n", 8); mb_internal_encoding(RCMAIL_CHARSET); } diff --unified --recursive roundcubemail-0.8.1/program/steps/settings/func.inc roundcubemail-0.8.1p-ja/program/steps/settings/func.inc --- roundcubemail-0.8.1/program/steps/settings/func.inc 2012-08-18 04:32:12.000000000 +0900 +++ roundcubemail-0.8.1p-ja/program/steps/settings/func.inc 2012-08-27 17:56:52.000000000 +0900 @@ -517,6 +517,16 @@ ); } + if (!isset($no_override['head_encoding_base64'])) { + $field_id = 'rcmfd_head_encoding_base64'; + $input_7bit = new html_checkbox(array('name' => '_head_encoding_base64', 'id' => $field_id, 'value' => 1)); + + $blocks['main']['options']['head_encoding_base64'] = array( + 'title' => html::label($field_id, Q(rcube_label('encodingbase64'))), + 'content' => $input_7bit->show($config['head_encoding_base64']?1:0), + ); + } + if (!isset($no_override['mdn_default'])) { $field_id = 'rcmfd_mdn_default'; $input_mdn = new html_checkbox(array('name' => '_mdn_default', 'id' => $field_id, 'value' => 1)); @@ -560,6 +570,17 @@ ); } + if (!isset($no_override['send_charset'])) { + $field_id = 'rcmfd_send_charset'; + + $blocks['main']['options']['send_charset'] = array( + 'title' => html::label($field_id, Q(rcube_label('defaultcharset'))), + 'content' => $RCMAIL->output->charset_selector(array( + 'name' => '_send_charset', 'selected' => $config['send_charset'] + )) + ); + } + if (!isset($no_override['spellcheck_before_send']) && $config['enable_spellcheck']) { $field_id = 'rcmfd_spellcheck_before_send'; $input_spellcheck = new html_checkbox(array('name' => '_spellcheck_before_send', 'id' => $field_id, 'value' => 1)); diff --unified --recursive roundcubemail-0.8.1/program/steps/settings/save_prefs.inc roundcubemail-0.8.1p-ja/program/steps/settings/save_prefs.inc --- roundcubemail-0.8.1/program/steps/settings/save_prefs.inc 2012-08-18 04:32:12.000000000 +0900 +++ roundcubemail-0.8.1p-ja/program/steps/settings/save_prefs.inc 2012-08-27 17:56:52.000000000 +0900 @@ -77,6 +77,7 @@ 'draft_autosave' => isset($_POST['_draft_autosave']) ? intval($_POST['_draft_autosave']) : 0, 'mime_param_folding' => isset($_POST['_mime_param_folding']) ? intval($_POST['_mime_param_folding']) : 0, 'force_7bit' => isset($_POST['_force_7bit']) ? TRUE : FALSE, + 'head_encoding_base64' => isset($_POST['_head_encoding_base64']) ? TRUE : FALSE, 'mdn_default' => isset($_POST['_mdn_default']) ? TRUE : FALSE, 'dsn_default' => isset($_POST['_dsn_default']) ? TRUE : FALSE, 'reply_same_folder' => isset($_POST['_reply_same_folder']) ? TRUE : FALSE, @@ -88,6 +89,7 @@ 'top_posting' => !empty($_POST['_top_posting']), 'strip_existing_sig' => isset($_POST['_strip_existing_sig']), 'sig_above' => !empty($_POST['_sig_above']) && !empty($_POST['_top_posting']), + 'send_charset' => get_input_value('_send_charset', RCUBE_INPUT_POST), 'default_font' => get_input_value('_default_font', RCUBE_INPUT_POST), 'forward_attachment' => !empty($_POST['_forward_attachment']), ); diff --unified --recursive roundcubemail-0.8.1/skins/classic/templates/compose.html roundcubemail-0.8.1p-ja/skins/classic/templates/compose.html --- roundcubemail-0.8.1/skins/classic/templates/compose.html 2012-08-18 04:32:12.000000000 +0900 +++ roundcubemail-0.8.1p-ja/skins/classic/templates/compose.html 2012-08-27 17:56:52.000000000 +0900 @@ -145,6 +145,9 @@