Aleksander Machniak
2016-05-01 013aaeb895d3ec8f6758db4c2521599404ad22c7
CS improvements/fixes
2 files modified
71 ■■■■ changed files
program/steps/mail/compose.inc 3 ●●●●● patch | view | raw | blame | history
program/steps/mail/func.inc 68 ●●●● patch | view | raw | blame | history
program/steps/mail/compose.inc
@@ -1058,9 +1058,6 @@
    $reply_mode = intval($RCMAIL->config->get('reply_mode'));
    if (!$bodyIsHtml) {
        $body = preg_replace('/\r?\n/', "\n", $body);
        $body = trim($body, "\n");
        // soft-wrap and quote message text
        $body = rcmail_wrap_and_quote($body, $LINE_LENGTH);
program/steps/mail/func.inc
@@ -331,8 +331,9 @@
    $OUTPUT->add_label('from', 'to');
    // add id to message list table if not specified
    if (!strlen($attrib['id']))
    if (!strlen($attrib['id'])) {
        $attrib['id'] = 'rcubemessagelist';
    }
    // define list of cols to be displayed based on parameter or config
    if (empty($attrib['columns'])) {
@@ -531,11 +532,7 @@
        if (!empty($header->list_cols) && is_array($header->list_cols))
            $a_msg_cols = array_merge($a_msg_cols, $header->list_cols);
        $OUTPUT->command('add_message_row',
            $header->uid,
            $a_msg_cols,
            $a_msg_flags,
            $insert_top);
        $OUTPUT->command('add_message_row', $header->uid, $a_msg_cols, $a_msg_flags, $insert_top);
    }
    if ($RCMAIL->storage->get_threading()) {
@@ -655,8 +652,9 @@
{
    global $OUTPUT;
    if (empty($attrib['id']))
    if (empty($attrib['id'])) {
        $attrib['id'] = 'rcmailcontentwindow';
    }
    return $OUTPUT->frame($attrib, true);
}
@@ -665,8 +663,9 @@
{
    global $RCMAIL;
    if (!$attrib['id'])
    if (!$attrib['id']) {
        $attrib['id'] = 'rcmcountdisplay';
    }
    $RCMAIL->output->add_gui_object('countdisplay', $attrib['id']);
@@ -685,19 +684,21 @@
    $page_size = $RCMAIL->storage->get_pagesize();
    $start_msg = ($page-1) * $page_size + 1;
    $max       = $count;
    if ($count !== null)
        $max = $count;
    else if ($RCMAIL->action)
        $max = $RCMAIL->storage->count(NULL, $RCMAIL->storage->get_threading() ? 'THREADS' : 'ALL');
    if ($max === null && $RCMAIL->action) {
        $max = $RCMAIL->storage->count(null, $RCMAIL->storage->get_threading() ? 'THREADS' : 'ALL');
    }
    if ($max == 0)
    if (!$max) {
        $out = $RCMAIL->storage->get_search_set() ? $RCMAIL->gettext('nomessages') : $RCMAIL->gettext('mailboxempty');
    else
    }
    else {
        $out = $RCMAIL->gettext(array('name' => $RCMAIL->storage->get_threading() ? 'threadsfromto' : 'messagesfromto',
            'vars' => array('from'  => $start_msg,
            'to'    => min($max, $start_msg + $page_size - 1),
            'count' => $max)));
    }
    return rcube::Q($out);
}
@@ -706,8 +707,9 @@
{
    global $RCMAIL;
    if (!$attrib['id'])
    if (!$attrib['id']) {
        $attrib['id'] = 'rcmmailboxname';
    }
    $RCMAIL->output->add_gui_object('mailboxname', $attrib['id']);
@@ -725,15 +727,16 @@
    global $RCMAIL;
    $old_unseen = rcmail_get_unseen_count($mbox_name);
    $unseen     = $count;
    if ($count === null)
    if ($unseen === null) {
        $unseen = $RCMAIL->storage->count($mbox_name, 'UNSEEN', $force);
    else
        $unseen = $count;
    }
    if ($unseen != $old_unseen || ($mbox_name == 'INBOX'))
    if ($unseen != $old_unseen || ($mbox_name == 'INBOX')) {
        $RCMAIL->output->command('set_unread_count', $mbox_name, $unseen,
            ($mbox_name == 'INBOX'), $unseen && $mark ? $mark : '');
    }
    rcmail_set_unseen_count($mbox_name, $unseen);
@@ -966,10 +969,12 @@
        // now check for evil strings like expression, behavior or url()
        if (!preg_match('/expression|behavior|javascript:|import[^a]/i', $stripped)) {
            if (!$washtml->get_config('allow_remote') && stripos($stripped, 'url('))
            if (!$washtml->get_config('allow_remote') && stripos($stripped, 'url(')) {
                $washtml->extlinks = true;
            else
            }
            else {
                $out = html::tag('style', array('type' => 'text/css'), $content);
            }
            break;
        }
@@ -1020,8 +1025,6 @@
    $output_headers  = array();
    foreach ($standard_headers as $hkey) {
        $ishtml = false;
        if ($headers[$hkey])
            $value = $headers[$hkey];
        else if ($headers['others'][$hkey])
@@ -1032,6 +1035,7 @@
        if (in_array($hkey, $exclude_headers))
            continue;
        $ishtml       = false;
        $header_title = $RCMAIL->gettext(preg_replace('/(^mail-|-)/', '', $hkey));
        if ($hkey == 'date') {
@@ -1060,8 +1064,8 @@
            }
        }
        else if ($hkey == 'mail-reply-to') {
            if ($headers['mail-replyto'] != $headers['reply-to']
                && $headers['reply-to'] != $headers['from']
            if ($headers['mail-replyto'] != $headers['replyto']
                && $headers['replyto'] != $headers['from']
            ) {
                $header_value = rcmail_address_string($value, $attrib['max'], true,
                    $attrib['addicon'], $headers['charset'], $header_title);
@@ -1091,8 +1095,9 @@
                $attrib['addicon'], $headers['charset'], $header_title);
            $ishtml = true;
        }
        else if ($hkey == 'subject' && empty($value))
        else if ($hkey == 'subject' && empty($value)) {
            $header_value = $RCMAIL->gettext('nosubject');
        }
        else {
            $value        = is_array($value) ? implode(' ', $value) : $value;
            $header_value = trim(rcube_mime::decode_header($value, $headers['charset']));
@@ -1722,9 +1727,9 @@
function rcmail_wrap_and_quote($text, $length = 72)
{
    // Rebuild the message body with a maximum of $max chars, while keeping quoted message.
    $max = max(75, $length + 8);
    $max   = max(75, $length + 8);
    $lines = preg_split('/\r?\n/', trim($text));
    $out = '';
    $out   = '';
    foreach ($lines as $line) {
        // don't wrap already quoted lines
@@ -1735,10 +1740,7 @@
            $newline = '';
            foreach (explode("\n", rcube_mime::wordwrap($line, $length - 2)) as $l) {
                if (strlen($l))
                    $newline .= '> ' . $l . "\n";
                else
                    $newline .= ">\n";
                $newline .= strlen($l) ? "> $l\n" : ">\n";
            }
            $line = rtrim($newline);
@@ -1758,7 +1760,7 @@
{
    $parts = array();
    foreach ($p as $key => $val) {
        $encode = $key == 'folder' || strpos($val, ';') !== false;
        $encode  = $key == 'folder' || strpos($val, ';') !== false;
        $parts[] = $key . '=' . ($encode ? 'B::' . base64_encode($val) : $val);
    }