From ec045b0a24bbb0de2b203961b453a9f5bd640f34 Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Tue, 22 Mar 2011 03:49:43 -0400
Subject: [PATCH] Revert r4609 and use stateless request tokens; no need to save them in session and thus no keep-alive necessary; fixes #1487829

---
 program/include/rcmail.php |   11 ++++-------
 1 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/program/include/rcmail.php b/program/include/rcmail.php
index d9bb30b..0fc7446 100644
--- a/program/include/rcmail.php
+++ b/program/include/rcmail.php
@@ -1106,12 +1106,8 @@
    */
   public function get_request_token()
   {
-    $key = $this->task;
-
-    if (!$_SESSION['request_tokens'][$key])
-      $_SESSION['request_tokens'][$key] = md5(uniqid($key . mt_rand(), true));
-
-    return $_SESSION['request_tokens'][$key];
+    $sess_id = $_COOKIE[ini_get('session.name')];
+    return md5('RT' . $this->task . $this->config->get('des_key') . $sess_id);
   }
 
 
@@ -1124,7 +1120,8 @@
   public function check_request($mode = RCUBE_INPUT_POST)
   {
     $token = get_input_value('_token', $mode);
-    return !empty($token) && $_SESSION['request_tokens'][$this->task] == $token;
+    $sess_id = $_COOKIE[ini_get('session.name')];
+    return !empty($sess_id) && $token == $this->get_request_token();
   }
 
 

--
Gitblit v1.9.1