From 617b4f699f2e47991c50e05528b1f9ecbc3c3d9c Mon Sep 17 00:00:00 2001
From: svncommit <devs@roundcube.net>
Date: Tue, 12 May 2009 09:26:07 -0400
Subject: [PATCH] Minimize chance of race condition in session handling (#1485659, #1484678)

---
 program/include/rcmail.php |   29 ++++++++++-------------------
 1 files changed, 10 insertions(+), 19 deletions(-)

diff --git a/program/include/rcmail.php b/program/include/rcmail.php
index 56fc2f5..45b59ae 100644
--- a/program/include/rcmail.php
+++ b/program/include/rcmail.php
@@ -91,7 +91,7 @@
     }
 
     // set task and action properties
-    $this->set_task(strip_quotes(get_input_value('_task', RCUBE_INPUT_GPC)));
+    $this->set_task(get_input_value('_task', RCUBE_INPUT_GPC));
     $this->action = asciiwords(get_input_value('_action', RCUBE_INPUT_GPC));
 
     // connect to database
@@ -124,7 +124,7 @@
 
     // reset some session parameters when changing task
     if ($_SESSION['task'] != $this->task)
-      unset($_SESSION['page']);
+      rcube_sess_unset('page');
 
     // set current task to session
     $_SESSION['task'] = $this->task;
@@ -145,14 +145,12 @@
    */
   public function set_task($task)
   {
-    if (!in_array($task, self::$main_tasks))
-      $task = 'mail';
-    
-    $this->task = $task;
-    $this->comm_path = $this->url(array('task' => $task));
+    $task = asciiwords($task);
+    $this->task = $task ? $task : 'mail';
+    $this->comm_path = $this->url(array('task' => $this->task));
     
     if ($this->output)
-      $this->output->set_env('task', $task);
+      $this->output->set_env('task', $this->task);
   }
   
   
@@ -371,13 +369,9 @@
     $options = array(
       'imap' => $this->config->get('imap_auth_type', 'check'),
       'delimiter' => isset($_SESSION['imap_delimiter']) ? $_SESSION['imap_delimiter'] : $this->config->get('imap_delimiter'),
+      'rootdir' => isset($_SESSION['imap_root']) ? $_SESSION['imap_root'] : $this->config->get('imap_root'),
     );
-    
-    if (isset($_SESSION['imap_root']))
-      $options['rootdir'] = $_SESSION['imap_root'];
-    else if ($imap_root = $this->config->get('imap_root'))
-      $options['rootdir'] = $imap_root;
-    
+
     $this->imap->set_options($options);
   
     // set global object for backward compatibility
@@ -940,11 +934,8 @@
   {
     if (!is_array($p))
       $p = array('_action' => @func_get_arg(0));
-      
-    $task = $p['_task'] ? $p['_task'] : $p['task'];
-    if (!$task || !in_array($task, rcmail::$main_tasks))
-      $task = $this->task;
-
+    
+    $task = $p['_task'] ? $p['_task'] : ($p['task'] ? $p['task'] : $this->task);
     $p['_task'] = $task;
     unset($p['task']);
 

--
Gitblit v1.9.1