thomascube
2007-11-25 d5342aabcfeddb959cc286befe6de5bf35fe9d76
More input sanitizing

4 files modified
44 ■■■■■ changed files
program/include/main.inc 8 ●●●●● patch | view | raw | blame | history
program/include/rcube_imap.inc 30 ●●●● patch | view | raw | blame | history
program/steps/mail/func.inc 4 ●●●● patch | view | raw | blame | history
program/steps/mail/rss.inc 2 ●●● patch | view | raw | blame | history
program/include/main.inc
@@ -1279,6 +1279,14 @@
    return $value;
  }
/**
 * Remove all non-ascii and non-word chars
 * except . and -
 */
function asciiwords($str)
{
  return preg_replace('/[^a-z0-9.-_]/i', '', $str);
}
/**
 * Remove single and double quotes from given string
program/include/rcube_imap.inc
@@ -5,7 +5,7 @@
 | program/include/rcube_imap.inc                                        |
 |                                                                       |
 | This file is part of the RoundCube Webmail client                     |
 | Copyright (C) 2005-2006, RoundCube Dev. - Switzerland                 |
 | Copyright (C) 2005-2007, RoundCube Dev. - Switzerland                 |
 | Licensed under the GNU GPL                                            |
 |                                                                       |
 | PURPOSE:                                                              |
@@ -35,7 +35,7 @@
 *
 * @package    Mail
 * @author     Thomas Bruederli <roundcube@gmail.com>
 * @version    1.39
 * @version    1.40
 * @link       http://ilohamail.org
 */
class rcube_imap
@@ -527,10 +527,7 @@
    if ($this->search_string && $mailbox == $this->mailbox)
      return $this->_list_header_set($mailbox, $this->search_set, $page, $sort_field, $sort_order);
    if ($sort_field!=NULL)
      $this->sort_field = $sort_field;
    if ($sort_order!=NULL)
      $this->sort_order = strtoupper($sort_order);
    $this->_set_sort_order($sort_field, $sort_order);
    $max = $this->_messagecount($mailbox);
    $start_msg = ($this->list_page-1) * $this->page_size;
@@ -647,10 +644,7 @@
    if (!strlen($mailbox) || empty($msgs))
      return array();
    if ($sort_field!=NULL)
      $this->sort_field = $sort_field;
    if ($sort_order!=NULL)
      $this->sort_order = strtoupper($sort_order);
    $this->_set_sort_order($sort_field, $sort_order);
    $max = count($msgs);
    $start_msg = ($this->list_page-1) * $this->page_size;
@@ -764,10 +758,7 @@
   */
  function message_index($mbox_name='', $sort_field=NULL, $sort_order=NULL)
    {
    if ($sort_field!=NULL)
      $this->sort_field = $sort_field;
    if ($sort_order!=NULL)
      $this->sort_order = strtoupper($sort_order);
    $this->_set_sort_order($sort_field, $sort_order);
    $mailbox = $mbox_name ? $this->_mod_mailbox($mbox_name) : $this->mailbox;
    $key = "$mbox:".$this->sort_field.":".$this->sort_order.".msgi";
@@ -2445,6 +2436,17 @@
    return $mbox_name;
    }
  /**
   * Validate the given input and save to local properties
   * @access private
   */
  function _set_sort_order($sort_field, $sort_order)
  {
    if ($sort_field != null)
      $this->sort_field = asciiwords($sort_field);
    if ($sort_order != null)
      $this->sort_order = strtoupper($sort_order) == 'DESC' ? 'DESC' : 'ASC';
  }
  /**
   * Sort mailboxes first by default folders and then in alphabethical order
program/steps/mail/func.inc
@@ -1191,7 +1191,7 @@
  {
  global $CONFIG, $IMAP, $MESSAGE;
  
  $part = get_input_value('_part', RCUBE_INPUT_GPC);
  $part = asciiwords(get_input_value('_part', RCUBE_INPUT_GPC));
  if (!is_array($MESSAGE) || !is_array($MESSAGE['parts']) || !($_GET['_uid'] && $_GET['_part']) || !$MESSAGE['parts'][$part])
    return '';
    
@@ -1225,7 +1225,7 @@
  {
  global $MESSAGE;
  
  $part = $MESSAGE['parts'][get_input_value('_part', RCUBE_INPUT_GPC)];
  $part = $MESSAGE['parts'][asciiwords(get_input_value('_part', RCUBE_INPUT_GPC))];
  $ctype_primary = strtolower($part->ctype_primary);
  $attrib['src'] = Q('./?'.str_replace('_frame=', ($ctype_primary=='text' ? '_show=' : '_preload='), $_SERVER['QUERY_STRING']));
program/steps/mail/rss.inc
@@ -79,7 +79,7 @@
// Check if the user wants to override the default sortingmethode
if (isset($_GET['_sort']))
  list($sort_col, $sort_order) = explode('_', $_GET['_sort']);
  list($sort_col, $sort_order) = explode('_', get_input_value('_sort', RCUBE_INPUT_GET));
// Add message to output
if ($messagecount > 0)