Skip to content

Commit

Permalink
Bugfixes for encoding and sending with attachments
Browse files Browse the repository at this point in the history
  • Loading branch information
thomascube committed Feb 4, 2006
1 parent 76ffa2a commit 58e3602
Show file tree
Hide file tree
Showing 16 changed files with 91 additions and 26 deletions.
5 changes: 3 additions & 2 deletions .htaccess
@@ -1,5 +1,6 @@
php_flag display_errors On AddDefaultCharset UTF-8
php_value upload_max_filesize 2m php_flag display_errors On
php_value upload_max_filesize 2m


<FilesMatch "(\.inc|\~)$|^_"> <FilesMatch "(\.inc|\~)$|^_">
Order allow,deny Order allow,deny
Expand Down
7 changes: 5 additions & 2 deletions CHANGELOG
@@ -1,9 +1,9 @@
CHANGELOG RoundCube Webmail CHANGELOG RoundCube Webmail
--------------------------- ---------------------------


2006/01/19 2006/02/04
---------- ----------
- Added Slovak translation - Added Slovak, Hungarian, Bosnian and Croation translation
- Fixed bug when inserting signatures with !?& - Fixed bug when inserting signatures with !?&
- Chopping message headers before inserting into the message cache table (to avoid bugs in Postgres) - Chopping message headers before inserting into the message cache table (to avoid bugs in Postgres)
- Allow one-char domains in e-mail addresses - Allow one-char domains in e-mail addresses
Expand All @@ -20,6 +20,9 @@ CHANGELOG RoundCube Webmail
- Added LDAP public search (experimental) - Added LDAP public search (experimental)
- Applied patch for correct ctrl/shift behavior for message selection (Bug #1326364) - Applied patch for correct ctrl/shift behavior for message selection (Bug #1326364)
- Casting to strings when adding empty headers to message cache (Bug #1406026) - Casting to strings when adding empty headers to message cache (Bug #1406026)
- Skip sender-address as recipient when Reply-to-all
- Fixes in utf8-class
- Added patch for Quota display by Aury Fink Filho <nuny@aury.com.br>




2005/12/16 2005/12/16
Expand Down
2 changes: 1 addition & 1 deletion SQL/sqlite.initial.sql
Expand Up @@ -31,7 +31,7 @@ CREATE INDEX ix_cache_session_id ON cache(session_id);
CREATE TABLE contacts ( CREATE TABLE contacts (
contact_id integer NOT NULL PRIMARY KEY, contact_id integer NOT NULL PRIMARY KEY,
user_id integer NOT NULL default '0', user_id integer NOT NULL default '0',
created datetime NOT NULL default '0000-00-00 00:00:00', changed datetime NOT NULL default '0000-00-00 00:00:00',
del tinyint NOT NULL default '0', del tinyint NOT NULL default '0',
name varchar(128) NOT NULL default '', name varchar(128) NOT NULL default '',
email varchar(128) NOT NULL default '', email varchar(128) NOT NULL default '',
Expand Down
2 changes: 1 addition & 1 deletion config/main.inc.php.dist
Expand Up @@ -85,7 +85,7 @@ $rcmail_config['session_lifetime'] = 10;
// check client IP in session athorization // check client IP in session athorization
$rcmail_config['ip_check'] = TRUE; $rcmail_config['ip_check'] = TRUE;


// not sure what this was good for :-) // the default locale setting
$rcmail_config['locale_string'] = 'en'; $rcmail_config['locale_string'] = 'en';


// use this format for short date display // use this format for short date display
Expand Down
1 change: 1 addition & 0 deletions index.php
Expand Up @@ -63,6 +63,7 @@
ini_set('session.use_cookies', 1); ini_set('session.use_cookies', 1);
ini_set('session.gc_maxlifetime', 21600); ini_set('session.gc_maxlifetime', 21600);
ini_set('session.gc_divisor', 500); ini_set('session.gc_divisor', 500);
ini_set('magic_quotes_gpc', 0);
ini_set('error_reporting', E_ALL&~E_NOTICE); ini_set('error_reporting', E_ALL&~E_NOTICE);


// increase maximum execution time for php scripts // increase maximum execution time for php scripts
Expand Down
13 changes: 8 additions & 5 deletions program/include/main.inc
Expand Up @@ -71,7 +71,7 @@ function rcmail_startup($task='mail')


// we can use the database for storing session data // we can use the database for storing session data
// session queries do not work with MDB2 // session queries do not work with MDB2
if ($CONFIG['db_backend']!='mdb2' && is_object($DB) /* && $DB->db_provider!='sqlite' */) if ($CONFIG['db_backend']!='mdb2' && is_object($DB))
include_once('include/session.inc'); include_once('include/session.inc');




Expand Down Expand Up @@ -709,18 +709,20 @@ function rcube_charset_convert($str, $from, $to=NULL)
return $str; return $str;


// convert charset using iconv module // convert charset using iconv module
if (function_exists('iconv') && $from!='UTF-7' && $to!='UTF-7') { if (0 && function_exists('iconv') && $from!='UTF-7' && $to!='UTF-7') {
return iconv($from, $to, $str); return iconv($from, $to, $str);
} }


$conv = new utf8();

// convert string to UTF-8 // convert string to UTF-8
if ($from=='UTF-7') if ($from=='UTF-7')
$str = rcube_charset_convert(UTF7DecodeString($str), 'ISO-8859-1'); $str = rcube_charset_convert(UTF7DecodeString($str), 'ISO-8859-1');
else if ($from=='ISO-8859-1' && function_exists('utf8_encode')) else if ($from=='ISO-8859-1' && function_exists('utf8_encode'))
$str = utf8_encode($str); $str = utf8_encode($str);
else if ($from!='UTF-8') else if ($from!='UTF-8')
{ {
$conv = new utf8($from); $conv->loadCharset($from);
$str = $conv->strToUtf8($str); $str = $conv->strToUtf8($str);
} }


Expand All @@ -731,7 +733,7 @@ function rcube_charset_convert($str, $from, $to=NULL)
return utf8_decode($str); return utf8_decode($str);
else if ($to!='UTF-8') else if ($to!='UTF-8')
{ {
$conv = new utf8($to); $conv->loadCharset($to);
return $conv->utf8ToStr($str); return $conv->utf8ToStr($str);
} }


Expand Down Expand Up @@ -960,6 +962,7 @@ function rcube_xml_command($command, $str_attrib, $a_attrib=NULL)
'message' => 'rcmail_message_container', 'message' => 'rcmail_message_container',
'messages' => 'rcmail_message_list', 'messages' => 'rcmail_message_list',
'messagecountdisplay' => 'rcmail_messagecount_display', 'messagecountdisplay' => 'rcmail_messagecount_display',
'quotadisplay' => 'rcmail_quota_display',
'messageheaders' => 'rcmail_message_headers', 'messageheaders' => 'rcmail_message_headers',
'messagebody' => 'rcmail_message_body', 'messagebody' => 'rcmail_message_body',
'messageattachments' => 'rcmail_message_attachments', 'messageattachments' => 'rcmail_message_attachments',
Expand Down
16 changes: 16 additions & 0 deletions program/include/rcube_imap.inc
Expand Up @@ -1057,6 +1057,22 @@ class rcube_imap
} }




/**
* Get quota
* added by Nuny
*/
function get_quota()
{
if ($this->get_capability('QUOTA'))
{
$result = iil_C_GetQuota($this->conn);
return sprintf("%.2fMB / %.2fMB (%.0f%%)", $result["used"] / 1000.0, $result["total"] / 1000.0, $result["percent"]);
}
else
return 'unknown';
}


// subscribe to a specific mailbox(es) // subscribe to a specific mailbox(es)
function subscribe($mbox, $mode='subscribe') function subscribe($mbox, $mode='subscribe')
{ {
Expand Down
9 changes: 8 additions & 1 deletion program/js/app.js
Expand Up @@ -231,7 +231,7 @@ function rcube_webmail()
this.enable_command('logout', true); this.enable_command('logout', true);


// disable browser's contextmenus // disable browser's contextmenus
//document.oncontextmenu = function(){ return false; } document.oncontextmenu = function(){ return false; }


// load body click event // load body click event
document.onmousedown = function(){ return rcube_webmail_client.reset_click(); }; document.onmousedown = function(){ return rcube_webmail_client.reset_click(); };
Expand Down Expand Up @@ -2645,6 +2645,13 @@ function rcube_webmail()
this.set_page_buttons(); this.set_page_buttons();
}; };


// replace content of quota display
this.set_quota = function(text)
{
if (this.gui_objects.quotadisplay)
this.gui_objects.quotadisplay.innerHTML = text;
};



// update the mailboxlist // update the mailboxlist
this.set_unread_count = function(mbox, count, set_title) this.set_unread_count = function(mbox, count, set_title)
Expand Down
9 changes: 5 additions & 4 deletions program/lib/utf8.class.php
Expand Up @@ -58,10 +58,10 @@
//Class definition //Class definition
Class utf8{ Class utf8{


var $charset = CP1250; var $charset = "ISO-8859-1";
var $ascMap = array(); var $ascMap = array();
var $utfMap = array(); var $utfMap = array();

// made PHP5 capable by RoundCube // made PHP5 capable by RoundCube
function __construct($charset="ISO-8859-1"){ function __construct($charset="ISO-8859-1"){
$this->loadCharset($charset); $this->loadCharset($charset);
Expand All @@ -75,7 +75,7 @@ function utf8($charset="ISO-8859-1"){
//Load charset //Load charset
function loadCharset($charset){ function loadCharset($charset){
global $utf8_maps; global $utf8_maps;

if (!is_file($utf8_maps[$charset])) if (!is_file($utf8_maps[$charset]))
{ {
$this->onError(ERR_OPEN_MAP_FILE, "Failed to open map file for $charset"); $this->onError(ERR_OPEN_MAP_FILE, "Failed to open map file for $charset");
Expand Down Expand Up @@ -170,4 +170,5 @@ function _utf8ToChar(&$chars, &$idx){
} }


} }
?>
?>
5 changes: 3 additions & 2 deletions program/steps/mail/check_recent.inc
Expand Up @@ -30,7 +30,8 @@ if ($recent_count = $IMAP->messagecount(NULL, 'RECENT', TRUE))
$commands = sprintf("this.set_unread_count('%s', %d, true);\n", addslashes($mbox), $unread_count); $commands = sprintf("this.set_unread_count('%s', %d, true);\n", addslashes($mbox), $unread_count);
$commands .= sprintf("this.set_env('messagecount', %d);\n", $count); $commands .= sprintf("this.set_env('messagecount', %d);\n", $count);
$commands .= sprintf("this.set_rowcount('%s');\n", rcmail_get_messagecount_text()); $commands .= sprintf("this.set_rowcount('%s');\n", rcmail_get_messagecount_text());

$commands .= sprintf("this.set_quota('%s');\n", $IMAP->get_quota());

// add new message headers to list // add new message headers to list
$a_headers = array(); $a_headers = array();
for ($i=$recent_count, $id=$count-$recent_count+1; $i>0; $i--, $id++) for ($i=$recent_count, $id=$count-$recent_count+1; $i>0; $i--, $id++)
Expand All @@ -44,4 +45,4 @@ if (strtoupper($mbox)!='INBOX' && $IMAP->messagecount('INBOX', 'RECENT'))




rcube_remote_response($commands); rcube_remote_response($commands);
?> ?>
9 changes: 8 additions & 1 deletion program/steps/mail/compose.inc
Expand Up @@ -145,8 +145,10 @@ function rcmail_compose_headers($attrib)
// get recipent address(es) out of the message headers // get recipent address(es) out of the message headers
if ($header=='to' && $REPLY_MESSAGE['headers']->replyto) if ($header=='to' && $REPLY_MESSAGE['headers']->replyto)
$fvalue = $IMAP->decode_header($REPLY_MESSAGE['headers']->replyto); $fvalue = $IMAP->decode_header($REPLY_MESSAGE['headers']->replyto);

else if ($header=='to' && $REPLY_MESSAGE['headers']->from) else if ($header=='to' && $REPLY_MESSAGE['headers']->from)
$fvalue = $IMAP->decode_header($REPLY_MESSAGE['headers']->from); $fvalue = $IMAP->decode_header($REPLY_MESSAGE['headers']->from);

// add recipent of original message if reply to all // add recipent of original message if reply to all
else if ($header=='cc' && $REPLY_MESSAGE['reply_all']) else if ($header=='cc' && $REPLY_MESSAGE['reply_all'])
{ {
Expand All @@ -169,7 +171,7 @@ function rcmail_compose_headers($attrib)
$fvalue = ''; $fvalue = '';
foreach ($to_addresses as $addr_part) foreach ($to_addresses as $addr_part)
{ {
if (!in_array($addr_part['mailto'], $sa_recipients)) if (!in_array($addr_part['mailto'], $sa_recipients) && (!$REPLY_MESSAGE['FROM'] || !in_array($addr_part['mailto'], $REPLY_MESSAGE['FROM'])))
{ {
$fvalue .= (strlen($fvalue) ? ', ':'').$addr_part['string']; $fvalue .= (strlen($fvalue) ? ', ':'').$addr_part['string'];
$sa_recipients[] = $addr_part['mailto']; $sa_recipients[] = $addr_part['mailto'];
Expand Down Expand Up @@ -214,6 +216,8 @@ function rcmail_compose_header_from($attrib)
$a_recipients = array(); $a_recipients = array();
if ($REPLY_MESSAGE && is_object($REPLY_MESSAGE['headers'])) if ($REPLY_MESSAGE && is_object($REPLY_MESSAGE['headers']))
{ {
$REPLY_MESSAGE['FROM'] = array();

$a_to = $IMAP->decode_address_list($REPLY_MESSAGE['headers']->to); $a_to = $IMAP->decode_address_list($REPLY_MESSAGE['headers']->to);
foreach ($a_to as $addr) foreach ($a_to as $addr)
{ {
Expand Down Expand Up @@ -259,6 +263,9 @@ function rcmail_compose_header_from($attrib)
// set identity if it's one of the reply-message recipients // set identity if it's one of the reply-message recipients
if (in_array($sql_arr['email'], $a_recipients)) if (in_array($sql_arr['email'], $a_recipients))
$from_id = $sql_arr['identity_id']; $from_id = $sql_arr['identity_id'];

if ($REPLY_MESSAGE && is_array($REPLY_MESSAGE['FROM']))
$REPLY_MESSAGE['FROM'][] = $sql_arr['email'];
} }


// overwrite identity selection with post parameter // overwrite identity selection with post parameter
Expand Down
24 changes: 21 additions & 3 deletions program/steps/mail/func.inc
Expand Up @@ -545,6 +545,25 @@ function rcmail_messagecount_display($attrib)
} }




function rcmail_quota_display($attrib)
{
global $IMAP, $OUTPUT, $JS_OBJECT_NAME;

if (!$attrib['id'])
$attrib['id'] = 'rcmquotadisplay';

$OUTPUT->add_script(sprintf("%s.gui_object('quotadisplay', '%s');", $JS_OBJECT_NAME, $attrib['id']));

// allow the following attributes to be added to the <span> tag
$attrib_str = create_attrib_string($attrib, array('style', 'class', 'id'));


$out = '<span' . $attrib_str . '>';
$out .= $IMAP->get_quota();
$out .= '</span>';
return $out;
}



function rcmail_get_messagecount_text() function rcmail_get_messagecount_text()
{ {
Expand Down Expand Up @@ -580,10 +599,9 @@ function rcmail_print_body($part, $safe=FALSE, $plain=FALSE) // $body, $ctype_pr
extract($part); extract($part);


$block = $plain ? '%s' : '%s'; //'<div style="display:block;">%s</div>'; $block = $plain ? '%s' : '%s'; //'<div style="display:block;">%s</div>';
$body = $IMAP->mime_decode($body, $encoding); $body = $IMAP->mime_decode($body, $encoding);
$body = $IMAP->charset_decode($body, $parameters); $body = $IMAP->charset_decode($body, $parameters);



// text/html // text/html
if ($ctype_secondary=='html') if ($ctype_secondary=='html')
{ {
Expand Down Expand Up @@ -804,7 +822,7 @@ function rcmail_parse_message($structure, $arg=array(), $recursive=FALSE)
} }


// part text/[plain|html] OR message/delivery-status // part text/[plain|html] OR message/delivery-status
else if (($primary_type=='text' && ($secondary_type=='plain' || $secondary_type=='html')) || else if (($primary_type=='text' && ($secondary_type=='plain' || $secondary_type=='html') && $mail_part->disposition!='attachment') ||
($primary_type=='message' && $secondary_type=='delivery-status')) ($primary_type=='message' && $secondary_type=='delivery-status'))
{ {
$a_return_parts[] = array('type' => 'content', $a_return_parts[] = array('type' => 'content',
Expand Down
1 change: 1 addition & 0 deletions program/steps/mail/move_del.inc
Expand Up @@ -73,6 +73,7 @@ $commands .= sprintf("this.set_unread_count('%s', %d);\n", $mbox, $IMAP->message
if ($_action=='moveto') if ($_action=='moveto')
$commands .= sprintf("this.set_unread_count('%s', %d);\n", $_GET['_target_mbox'], $IMAP->messagecount($_GET['_target_mbox'], 'UNSEEN')); $commands .= sprintf("this.set_unread_count('%s', %d);\n", $_GET['_target_mbox'], $IMAP->messagecount($_GET['_target_mbox'], 'UNSEEN'));


$commands .= sprintf("this.set_quota('%s');\n", $IMAP->get_quota());


// add new rows from next page (if any) // add new rows from next page (if any)
if ($_GET['_from']!='show' && $pages>1 && $IMAP->list_page < $pages) if ($_GET['_from']!='show' && $pages>1 && $IMAP->list_page < $pages)
Expand Down
6 changes: 3 additions & 3 deletions program/steps/mail/sendmail.inc
Expand Up @@ -115,7 +115,7 @@ if (strlen($identity_arr['bcc']))
$headers['Bcc'] = ($headers['Bcc'] ? $headers['Bcc'].', ' : '') . $identity_arr['bcc']; $headers['Bcc'] = ($headers['Bcc'] ? $headers['Bcc'].', ' : '') . $identity_arr['bcc'];


// add subject // add subject
$headers['Subject'] = rcube_charset_convert(trim(stripslashes($_POST['_subject'])), $input_charset, $message_charset); $headers['Subject'] = rcube_charset_convert(trim($_POST['_subject']), $input_charset, $message_charset);


if (strlen($identity_arr['organization'])) if (strlen($identity_arr['organization']))
$headers['Organization'] = $identity_arr['organization']; $headers['Organization'] = $identity_arr['organization'];
Expand Down Expand Up @@ -144,7 +144,7 @@ if ($CONFIG['useragent'])
$headers['User-Agent'] = $CONFIG['useragent']; $headers['User-Agent'] = $CONFIG['useragent'];


// fetch message body // fetch message body
$message_body = rcube_charset_convert(stripslashes($_POST['_message']), $input_charset, $message_charset); $message_body = rcube_charset_convert($_POST['_message'], $input_charset, $message_charset);


// append generic footer to all messages // append generic footer to all messages
if (!empty($CONFIG['generic_message_footer'])) if (!empty($CONFIG['generic_message_footer']))
Expand Down Expand Up @@ -225,7 +225,7 @@ if ($CONFIG['smtp_server'])
else else
{ {
// unset some headers because they will be added by the mail() function // unset some headers because they will be added by the mail() function
$headers_php = $headers; $headers_php = $MAIL_MIME->_headers;
$headers_enc = $MAIL_MIME->headers($headers); $headers_enc = $MAIL_MIME->headers($headers);
unset($headers_php['To'], $headers_php['Subject']); unset($headers_php['To'], $headers_php['Subject']);


Expand Down
5 changes: 5 additions & 0 deletions skins/default/mail.css
Expand Up @@ -749,3 +749,8 @@ div.message-part pre
margin-top: 8px; margin-top: 8px;
} }


#rcmquotadisplay
{
color: #999999;
font-size: 11px;
}
3 changes: 2 additions & 1 deletion skins/default/templates/mail.html
Expand Up @@ -50,7 +50,8 @@
<roundcube:label name="select" />:&nbsp; <roundcube:label name="select" />:&nbsp;
<roundcube:button command="select-all" label="all" classAct="active" />&nbsp; <roundcube:button command="select-all" label="all" classAct="active" />&nbsp;
<roundcube:button command="select-all" prop="unread" label="unread" classAct="active" />&nbsp; <roundcube:button command="select-all" prop="unread" label="unread" classAct="active" />&nbsp;
<roundcube:button command="select-none" label="none" classAct="active" /> <roundcube:button command="select-none" label="none" classAct="active" /> &nbsp;&nbsp;&nbsp;
<roundcube:label name="quota" />: <roundcube:object name="quotaDisplay" />
</div> </div>


</body> </body>
Expand Down

0 comments on commit 58e3602

Please sign in to comment.