From 197203727417a03d87053a47e5aa5175a76e3e0b Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Thu, 17 Oct 2013 04:24:53 -0400
Subject: [PATCH] Fix vulnerability in handling _session argument of utils/save-prefs (#1489382)

---
 program/include/rcube_plugin_api.php |   22 +++++++++++++++++++---
 1 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/program/include/rcube_plugin_api.php b/program/include/rcube_plugin_api.php
index cfba7fa..81c483b 100644
--- a/program/include/rcube_plugin_api.php
+++ b/program/include/rcube_plugin_api.php
@@ -27,12 +27,14 @@
 class rcube_plugin_api
 {
   static private $instance;
-  
+
   public $dir;
   public $url = 'plugins/';
   public $output;
   public $config;
-  
+  public $allowed_prefs         = array();
+  public $allowed_session_prefs = array();
+
   public $handlers = array();
   private $plugins = array();
   private $tasks = array();
@@ -176,11 +178,14 @@
         if (is_subclass_of($plugin, 'rcube_plugin')) {
           // ... task, request type and framed mode
           if ((!$plugin->task || preg_match('/^('.$plugin->task.')$/i', $rcmail->task))
-              && (!$plugin->noajax || is_a($rcmail->output, 'rcube_template'))
+              && (!$plugin->noajax || (is_object($rcmail->output) && is_a($rcmail->output, 'rcube_template')))
               && (!$plugin->noframe || empty($_REQUEST['_framed']))
           ) {
             $plugin->init();
             $this->plugins[$plugin_name] = $plugin;
+          }
+          if (!empty($plugin->allowed_prefs)) {
+            $this->allowed_prefs = array_merge($this->allowed_prefs, $plugin->allowed_prefs);
           }
           return true;
         }
@@ -422,6 +427,17 @@
 
 
   /**
+   * Returns list of loaded plugins names
+   *
+   * @return array List of plugin names
+   */
+  public function loaded_plugins()
+  {
+    return array_keys($this->plugins);
+  }
+
+
+  /**
    * Callback for template_container hooks
    *
    * @param array $attrib

--
Gitblit v1.9.1