summaryrefslogtreecommitdiff
path: root/program
diff options
context:
space:
mode:
Diffstat (limited to 'program')
-rw-r--r--program/include/main.inc19
-rw-r--r--program/include/rcube_imap.inc2
-rw-r--r--program/include/rcube_shared.inc8
-rw-r--r--program/steps/addressbook/save.inc6
-rw-r--r--program/steps/mail/get.inc4
-rw-r--r--program/steps/mail/sendmail.inc25
-rw-r--r--program/steps/settings/manage_folders.inc2
-rw-r--r--program/steps/settings/save_identity.inc6
8 files changed, 42 insertions, 30 deletions
diff --git a/program/include/main.inc b/program/include/main.inc
index 06d4d7b80..628866f35 100644
--- a/program/include/main.inc
+++ b/program/include/main.inc
@@ -308,11 +308,12 @@ function load_gui()
$OUTPUT->include_script('program/js/common.js');
$OUTPUT->include_script('program/js/app.js');
+ // set locale setting
+ rcmail_set_locale($sess_user_lang);
+
// set user-selected charset
if (!empty($CONFIG['charset']))
$OUTPUT->set_charset($CONFIG['charset']);
- else
- rcmail_set_locale($sess_user_lang);
// add some basic label to client
rcube_add_label('loading');
@@ -351,7 +352,7 @@ function rcmail_set_locale($lang)
if ($MBSTRING && function_exists("mb_language"))
{
- if (!mb_language(strtok($lang, "_")))
+ if (!@mb_language(strtok($lang, "_")))
$MBSTRING = FALSE; // unsupport language
}
@@ -662,6 +663,7 @@ function decrypt_passwd($cypher)
// send correct response on a remote request
function rcube_remote_response($js_code, $flush=FALSE)
{
+ global $OUTPUT, $CHARSET;
static $s_header_sent = FALSE;
if (!$s_header_sent)
@@ -673,7 +675,7 @@ function rcube_remote_response($js_code, $flush=FALSE)
}
// send response code
- print rcube_charset_convert($js_code, 'UTF-8', $GLOBALS['CHARSET']);
+ print rcube_charset_convert($js_code, $CHARSET, $OUTPUT->get_charset());
if ($flush) // flush the output buffer
flush();
@@ -888,7 +890,12 @@ function rep_specialchars_output($str, $enctype='', $mode='', $newlines=TRUE)
// encode for javascript use
if ($enctype=='js')
+ {
+ if ($OUTPUT->get_charset()!='UTF-8')
+ $str = rcube_charset_convert($str, $GLOBALS['CHARSET'], $OUTPUT->get_charset());
+
return preg_replace(array("/\r\n/", '/"/', "/([^\\\])'/"), array('\n', '\"', "$1\'"), strtr($str, $js_rep_table));
+ }
// encode for RTF
if ($enctype=='rtf')
@@ -1543,6 +1550,8 @@ EOF;
function rcmail_charset_selector($attrib)
{
+ global $OUTPUT;
+
// pass the following attributes to the form class
$field_attrib = array('name' => '_charset');
foreach ($attrib as $attr => $value)
@@ -1571,7 +1580,7 @@ function rcmail_charset_selector($attrib)
$select = new select($field_attrib);
$select->add(array_values($charsets), array_keys($charsets));
- $set = $_POST['_charset'] ? $_POST['_charset'] : $GLOBALS['CHARSET'];
+ $set = $_POST['_charset'] ? $_POST['_charset'] : $OUTPUT->get_charset();
return $select->show($set);
}
diff --git a/program/include/rcube_imap.inc b/program/include/rcube_imap.inc
index 9777d4c18..71a5cb6ac 100644
--- a/program/include/rcube_imap.inc
+++ b/program/include/rcube_imap.inc
@@ -444,7 +444,7 @@ class rcube_imap
$count = iil_C_CountMessages($this->conn, $mailbox);
}
- if (is_array($a_mailbox_cache[$mailbox]))
+ if (!is_array($a_mailbox_cache[$mailbox]))
$a_mailbox_cache[$mailbox] = array();
$a_mailbox_cache[$mailbox][$mode] = (int)$count;
diff --git a/program/include/rcube_shared.inc b/program/include/rcube_shared.inc
index 79428fa16..da5665199 100644
--- a/program/include/rcube_shared.inc
+++ b/program/include/rcube_shared.inc
@@ -86,13 +86,13 @@ class rcube_html_page
function set_charset($charset)
{
global $MBSTRING;
+
$this->charset = $charset;
- if ($MBSTRING&&function_exists( "mb_internal_encoding"))
+
+ if ($MBSTRING && function_exists("mb_internal_encoding"))
{
- if(!@mb_internal_encoding( $charset))
- {
+ if(!@mb_internal_encoding($charset))
$MBSTRING = FALSE;
- }
}
}
diff --git a/program/steps/addressbook/save.inc b/program/steps/addressbook/save.inc
index 24e375ef7..32a6243fd 100644
--- a/program/steps/addressbook/save.inc
+++ b/program/steps/addressbook/save.inc
@@ -42,7 +42,9 @@ if ($_POST['_cid'])
if (!isset($_POST[$fname]))
continue;
- $a_write_sql[] = sprintf("%s=%s", $DB->quoteIdentifier($col), $DB->quote(strip_tags($_POST[$fname])));
+ $a_write_sql[] = sprintf("%s=%s",
+ $DB->quoteIdentifier($col),
+ $DB->quote(rcube_charset_convert(strip_tags($_POST[$fname]), $OUTPUT->get_charset())));
}
if (sizeof($a_write_sql))
@@ -164,7 +166,7 @@ else
continue;
$a_insert_cols[] = $col;
- $a_insert_values[] = $DB->quote(strip_tags($_POST[$fname]));
+ $a_insert_values[] = $DB->quote(rcube_charset_convert(strip_tags($_POST[$fname]), $OUTPUT->get_charset()));
}
if (sizeof($a_insert_cols))
diff --git a/program/steps/mail/get.inc b/program/steps/mail/get.inc
index 5a4fea153..99cd211c6 100644
--- a/program/steps/mail/get.inc
+++ b/program/steps/mail/get.inc
@@ -70,8 +70,8 @@ else if ($_GET['_part'])
$mimetype = sprintf('%s/%s', $ctype_primary, $ctype_secondary);
$filename = $part->d_parameters['filename'] ? $part->d_parameters['filename'] : $part->ctype_parameters['name'];
-
- if ($ctype_primary=='text')
+
+ if ($ctype_primary=='text' && $ctype_secondary=='html')
{
list($MESSAGE['parts']) = rcmail_parse_message($part,
array('safe' => (bool)$_GET['_safe'],
diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc
index a520a5043..ec0f1166f 100644
--- a/program/steps/mail/sendmail.inc
+++ b/program/steps/mail/sendmail.inc
@@ -39,7 +39,7 @@ if (!isset($_SESSION['compose']['id']))
function rcmail_get_identity($id)
{
- global $DB;
+ global $DB, $CHARSET, $OUTPUT;
// get identity record
$sql_result = $DB->query("SELECT *, email AS mailto
@@ -53,7 +53,9 @@ function rcmail_get_identity($id)
{
$sql_arr = $DB->fetch_assoc($sql_result);
$out = $sql_arr;
- $out['string'] = sprintf('%s <%s>', $sql_arr['name'], $sql_arr['mailto']);
+ $out['string'] = sprintf('%s <%s>',
+ rcube_charset_convert($sql_arr['name'], $CHARSET, $OUTPUT->get_charset()),
+ $sql_arr['mailto']);
return $out;
}
@@ -74,10 +76,7 @@ if (empty($_POST['_to']) && empty($_POST['_subject']) && $_POST['_message'])
// set default charset
-if (empty($CHARSET))
- $CHARSET = 'ISO-8859-1';
-
-$input_charset = $CHARSET;
+$input_charset = $OUTPUT->get_charset();
$message_charset = isset($_POST['_charset']) ? $_POST['_charset'] : $input_charset;
$mailto_regexp = array('/[,;]\s*[\r\n]+/', '/[\r\n]+/', '/[,;]\s*$/m');
@@ -162,7 +161,7 @@ if (!empty($CONFIG['generic_message_footer']))
// use the configured delimiter for headers
-$header_delm = $rcmail_config['mail_header_delimiter'] ? $rcmail_config['mail_header_delimiter'] : "\r\n";
+$header_delm = $CONFIG['mail_header_delimiter'] ? $CONFIG['mail_header_delimiter'] : "\r\n";
// create PEAR::Mail_mime instance
$MAIL_MIME = new Mail_mime($header_delm);
@@ -198,9 +197,9 @@ $message_param = array('text_encoding' => $transfer_encoding,
$msg_body = $MAIL_MIME->get($message_param);
$msg_subject = $headers['Subject'];
-global $MBSTRING;
-if ($MBSTRING&&function_exists( "mb_encode_mimeheader"))
- $headers['Subject'] = mb_encode_mimeheader( $headers['Subject'],$message_charset);
+
+if ($MBSTRING && function_exists("mb_encode_mimeheader"))
+ $headers['Subject'] = mb_encode_mimeheader($headers['Subject'], $message_charset);
// send thru SMTP server using cusotm SMTP library
if ($CONFIG['smtp_server'])
@@ -238,15 +237,15 @@ if ($CONFIG['smtp_server'])
else
{
// unset some headers because they will be added by the mail() function
- $headers_php = $MAIL_MIME->_headers;
$headers_enc = $MAIL_MIME->headers($headers);
+ $headers_php = $MAIL_MIME->_headers;
unset($headers_php['To'], $headers_php['Subject']);
-
+
// reset stored headers and overwrite
$MAIL_MIME->_headers = array();
$header_str = $MAIL_MIME->txtHeaders($headers_php);
- if(ini_get('safe_mode'))
+ if (ini_get('safe_mode'))
$sent = mail($headers_enc['To'], $headers_enc['Subject'], $msg_body, $header_str);
else
$sent = mail($headers_enc['To'], $headers_enc['Subject'], $msg_body, $header_str, "-f$from");
diff --git a/program/steps/settings/manage_folders.inc b/program/steps/settings/manage_folders.inc
index c98de3951..6f49018e7 100644
--- a/program/steps/settings/manage_folders.inc
+++ b/program/steps/settings/manage_folders.inc
@@ -47,7 +47,7 @@ else if ($_action=='unsubscribe')
else if ($_action=='create-folder')
{
if (strlen($_GET['_name']))
- $create = $IMAP->create_mailbox(strip_tags(trim($_GET['_name'])), TRUE);
+ $create = $IMAP->create_mailbox(rcube_charset_convert(strip_tags(trim($_GET['_name'])), $OUTPUT->get_charset()), TRUE);
if ($create && $_GET['_remote'])
{
diff --git a/program/steps/settings/save_identity.inc b/program/steps/settings/save_identity.inc
index dc61b7875..1bfbf48e6 100644
--- a/program/steps/settings/save_identity.inc
+++ b/program/steps/settings/save_identity.inc
@@ -42,7 +42,9 @@ if ($_POST['_iid'])
if (!isset($_POST[$fname]))
continue;
- $a_write_sql[] = sprintf("%s=%s", $DB->quoteIdentifier($col), $DB->quote(strip_tags($_POST[$fname])));
+ $a_write_sql[] = sprintf("%s=%s",
+ $DB->quoteIdentifier($col),
+ $DB->quote(rcube_charset_convert(strip_tags($_POST[$fname]), $OUTPUT->get_charset())));
}
if (sizeof($a_write_sql))
@@ -97,7 +99,7 @@ else
continue;
$a_insert_cols[] = $DB->quoteIdentifier($col);
- $a_insert_values[] = $DB->quote(strip_tags($_POST[$fname]));
+ $a_insert_values[] = $DB->quote(rcube_charset_convert(strip_tags($_POST[$fname]), $OUTPUT->get_charset()));
}
if (sizeof($a_insert_cols))