Fix bugs caught by static analysis

pull/73/head
Aleksander Machniak 12 years ago
parent 3a0dc87856
commit c027ba7709

@ -433,8 +433,9 @@ class acl extends rcube_plugin
$acl = trim(rcube_utils::get_input_value('_acl', rcube_utils::INPUT_GPC)); $acl = trim(rcube_utils::get_input_value('_acl', rcube_utils::INPUT_GPC));
$oldid = trim(rcube_utils::get_input_value('_old', rcube_utils::INPUT_GPC)); $oldid = trim(rcube_utils::get_input_value('_old', rcube_utils::INPUT_GPC));
$acl = array_intersect(str_split($acl), $this->rights_supported()); $acl = array_intersect(str_split($acl), $this->rights_supported());
$users = $oldid ? array($user) : explode(',', $user); $users = $oldid ? array($user) : explode(',', $user);
$result = 0;
foreach ($users as $user) { foreach ($users as $user) {
$user = trim($user); $user = trim($user);

@ -183,7 +183,7 @@ class rcube_sql_password
$res = $db->query($sql, $sql_vars); $res = $db->query($sql, $sql_vars);
if (!$db->is_error()) { if (!$db->is_error()) {
if (strtolower(substr(trim($query),0,6))=='select') { if (strtolower(substr(trim($sql),0,6)) == 'select') {
if ($result = $db->fetch_array($res)) if ($result = $db->fetch_array($res))
return PASSWORD_SUCCESS; return PASSWORD_SUCCESS;
} else { } else {

@ -535,7 +535,7 @@ abstract class rcube_addressbook
*/ */
public static function compose_contact_key($contact, $sort_col) public static function compose_contact_key($contact, $sort_col)
{ {
$key = $contact[$sort_col] . ':' . $row['sourceid']; $key = $contact[$sort_col] . ':' . $contact['sourceid'];
// add email to a key to not skip contacts with the same name (#1488375) // add email to a key to not skip contacts with the same name (#1488375)
if (!empty($contact['email'])) { if (!empty($contact['email'])) {
@ -545,7 +545,6 @@ abstract class rcube_addressbook
return $key; return $key;
} }
/** /**
* Compare search value with contact data * Compare search value with contact data
* *

@ -147,7 +147,7 @@ class rcube_db_mysql extends rcube_db
$result = $this->query('SHOW VARIABLES'); $result = $this->query('SHOW VARIABLES');
while ($sql_arr = $this->fetch_array($result)) { while ($row = $this->fetch_array($result)) {
$this->variables[$row[0]] = $row[1]; $this->variables[$row[0]] = $row[1];
} }
} }

@ -981,7 +981,7 @@ class rcube_imap extends rcube_storage
// use memory less expensive (and quick) method for big result set // use memory less expensive (and quick) method for big result set
$index = clone $this->index('', $this->sort_field, $this->sort_order); $index = clone $this->index('', $this->sort_field, $this->sort_order);
// get messages uids for one page... // get messages uids for one page...
$index->slice($start_msg, min($cnt-$from, $this->page_size)); $index->slice($from, min($cnt-$from, $this->page_size));
if ($slice) { if ($slice) {
$index->slice(-$slice, $slice); $index->slice(-$slice, $slice);
@ -2727,7 +2727,7 @@ class rcube_imap extends rcube_storage
// filter folders list according to rights requirements // filter folders list according to rights requirements
if ($rights && $this->get_capability('ACL')) { if ($rights && $this->get_capability('ACL')) {
$a_folders = $this->filter_rights($a_folders, $rights); $a_mboxes = $this->filter_rights($a_mboxes, $rights);
} }
// filter folders and sort them // filter folders and sort them

@ -1077,7 +1077,7 @@ class rcube_imap_generic
} }
if (!$this->data['READ-WRITE']) { if (!$this->data['READ-WRITE']) {
$this->setError(self::ERROR_READONLY, "Mailbox is read-only", 'EXPUNGE'); $this->setError(self::ERROR_READONLY, "Mailbox is read-only");
return false; return false;
} }
@ -1936,7 +1936,7 @@ class rcube_imap_generic
} }
if (!$this->data['READ-WRITE']) { if (!$this->data['READ-WRITE']) {
$this->setError(self::ERROR_READONLY, "Mailbox is read-only", 'STORE'); $this->setError(self::ERROR_READONLY, "Mailbox is read-only");
return false; return false;
} }
@ -1997,7 +1997,7 @@ class rcube_imap_generic
} }
if (!$this->data['READ-WRITE']) { if (!$this->data['READ-WRITE']) {
$this->setError(self::ERROR_READONLY, "Mailbox is read-only", 'STORE'); $this->setError(self::ERROR_READONLY, "Mailbox is read-only");
return false; return false;
} }
@ -2508,7 +2508,7 @@ class rcube_imap_generic
$tokens = $this->tokenizeResponse(preg_replace('/(^\(|\)$)/', '', $line)); $tokens = $this->tokenizeResponse(preg_replace('/(^\(|\)$)/', '', $line));
for ($i=0; $i<count($tokens); $i+=2) { for ($i=0; $i<count($tokens); $i+=2) {
if (preg_match('/^(BODY|BINARY)/i', $token)) { if (preg_match('/^(BODY|BINARY)/i', $tokens[$i])) {
$result = $tokens[$i+1]; $result = $tokens[$i+1];
$found = true; $found = true;
break; break;

@ -593,7 +593,7 @@ class rcube_spellchecker
if (empty($plugin['abort'])) { if (empty($plugin['abort'])) {
$dict = array(); $dict = array();
$this->rc->db->query( $sql_result = $this->rc->db->query(
"SELECT data FROM ".$this->rc->db->table_name('dictionary') "SELECT data FROM ".$this->rc->db->table_name('dictionary')
." WHERE user_id ". ($plugin['userid'] ? "= ".$this->rc->db->quote($plugin['userid']) : "IS NULL") ." WHERE user_id ". ($plugin['userid'] ? "= ".$this->rc->db->quote($plugin['userid']) : "IS NULL")
." AND " . $this->rc->db->quoteIdentifier('language') . " = ?", ." AND " . $this->rc->db->quoteIdentifier('language') . " = ?",

@ -90,7 +90,7 @@ class rcube_vcard
*/ */
public function __construct($vcard = null, $charset = RCUBE_CHARSET, $detect = false, $fieldmap = array()) public function __construct($vcard = null, $charset = RCUBE_CHARSET, $detect = false, $fieldmap = array())
{ {
if (!empty($fielmap)) { if (!empty($fieldmap)) {
$this->extend_fieldmap($fieldmap); $this->extend_fieldmap($fieldmap);
} }

@ -60,8 +60,8 @@ Class utf8 {
function loadCharset($charset) { function loadCharset($charset) {
$charset = preg_replace(array('/^WINDOWS-*125([0-8])$/', '/^CP-/'), array('CP125\\1', 'CP'), $charset); $charset = preg_replace(array('/^WINDOWS-*125([0-8])$/', '/^CP-/'), array('CP125\\1', 'CP'), $charset);
if (isset($aliases[$charset])) if (isset($this->aliases[$charset]))
$charset = $aliases[$charset]; $charset = $this->aliases[$charset];
$this->charset = $charset; $this->charset = $charset;

@ -167,7 +167,7 @@ function rcmail_set_sourcename($abook)
// get address book name (for display) // get address book name (for display)
if ($abook && $_SESSION['addressbooks_count'] > 1) { if ($abook && $_SESSION['addressbooks_count'] > 1) {
$name = $abook->get_name(); $name = $abook->get_name();
if (!$name && $source == 0) { if (!$name) {
$name = rcube_label('personaladrbook'); $name = rcube_label('personaladrbook');
} }
$OUTPUT->set_env('sourcename', html_entity_decode($name, ENT_COMPAT, 'UTF-8')); $OUTPUT->set_env('sourcename', html_entity_decode($name, ENT_COMPAT, 'UTF-8'));

@ -88,7 +88,7 @@ function rcmail_import_confirm($attrib)
$content = html::p(null, rcube_label(array( $content = html::p(null, rcube_label(array(
'name' => 'importconfirm', 'name' => 'importconfirm',
'nr' => $IMORT_STATS->inserted, 'nr' => $IMPORT_STATS->inserted,
'vars' => $vars, 'vars' => $vars,
)) . ($IMPORT_STATS->names ? ':' : '.')); )) . ($IMPORT_STATS->names ? ':' : '.'));
@ -98,7 +98,7 @@ function rcmail_import_confirm($attrib)
if ($IMPORT_STATS->skipped) { if ($IMPORT_STATS->skipped) {
$content .= html::p(null, rcube_label(array( $content .= html::p(null, rcube_label(array(
'name' => 'importconfirmskipped', 'name' => 'importconfirmskipped',
'nr' => $IMORT_STATS->skipped, 'nr' => $IMPORT_STATS->skipped,
'vars' => $vars, 'vars' => $vars,
)) . ':'); )) . ':');
$content .= html::p('em', join(', ', array_map('Q', $IMPORT_STATS->skipped_names))); $content .= html::p('em', join(', ', array_map('Q', $IMPORT_STATS->skipped_names)));

@ -223,7 +223,7 @@ function rcmail_contact_record_groups($contact_id)
} }
$hiddenfields = new html_hiddenfield(array('name' => '_source', 'value' => get_input_value('_source', RCUBE_INPUT_GPC))); $hiddenfields = new html_hiddenfield(array('name' => '_source', 'value' => get_input_value('_source', RCUBE_INPUT_GPC)));
$hiddenfields->add(array('name' => '_cid', 'value' => $record['ID'])); $hiddenfields->add(array('name' => '_cid', 'value' => $contact_id));
$form_start = $RCMAIL->output->request_form(array( $form_start = $RCMAIL->output->request_form(array(
'name' => "form", 'method' => "post", 'name' => "form", 'method' => "post",

@ -639,7 +639,7 @@ function rcmail_prepare_message_body()
function rcmail_compose_part_body($part, $isHtml = false) function rcmail_compose_part_body($part, $isHtml = false)
{ {
global $RCMAIL, $MESSAGE, $compose_mode; global $RCMAIL, $MESSAGE, $LINE_LENGTH, $compose_mode;
// Check if we have enough memory to handle the message in it // Check if we have enough memory to handle the message in it
// #1487424: we need up to 10x more memory than the body // #1487424: we need up to 10x more memory than the body
@ -1224,10 +1224,11 @@ function rcmail_save_image($path, $mimetype='')
// handle attachments in memory // handle attachments in memory
$data = file_get_contents($path); $data = file_get_contents($path);
$name = rcmail_basename($path);
$attachment = array( $attachment = array(
'group' => $COMPOSE['id'], 'group' => $COMPOSE['id'],
'name' => rcmail_basename($path), 'name' => $name,
'mimetype' => $mimetype ? $mimetype : rc_mime_content_type($path, $name), 'mimetype' => $mimetype ? $mimetype : rc_mime_content_type($path, $name),
'data' => $data, 'data' => $data,
'size' => strlen($data), 'size' => strlen($data),

Loading…
Cancel
Save