From ed1d212ae2daea5e4bd043417610177093e99f19 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Sat, 16 Jan 2016 03:03:51 -0500
Subject: [PATCH] Improved SVG cleanup code

---
 program/lib/Roundcube/rcube_config.php |   80 +++++++++++++++++++--------------------
 1 files changed, 39 insertions(+), 41 deletions(-)

diff --git a/program/lib/Roundcube/rcube_config.php b/program/lib/Roundcube/rcube_config.php
index 89e4544..a58af37 100644
--- a/program/lib/Roundcube/rcube_config.php
+++ b/program/lib/Roundcube/rcube_config.php
@@ -1,6 +1,6 @@
 <?php
 
-/*
+/**
  +-----------------------------------------------------------------------+
  | This file is part of the Roundcube Webmail client                     |
  | Copyright (C) 2008-2014, The Roundcube Dev Team                       |
@@ -103,21 +103,21 @@
      */
     private function guess_type($value)
     {
-        $_ = 'string';
+        $type = 'string';
 
         // array requires hint to be passed.
 
         if (preg_match('/^[-+]?(\d+(\.\d*)?|\.\d+)([eE][-+]?\d+)?$/', $value) !== false) {
-            $_ = 'double';
+            $type = 'double';
         }
         else if (preg_match('/^\d+$/', $value) !== false) {
-            $_ = 'integer';
+            $type = 'integer';
         }
         else if (preg_match('/(t(rue)?)|(f(alse)?)/i', $value) !== false) {
-            $_ = 'boolean';
+            $type = 'boolean';
         }
 
-        return $_;
+        return $type;
     }
 
     /**
@@ -126,7 +126,7 @@
      * Perform an appropriate parsing of the string to create the desired PHP type.
      *
      * @param $string String to parse into PHP type
-     * @param $type Type of value to return
+     * @param $type   Type of value to return
      *
      * @return Appropriately typed interpretation of $string.
      */
@@ -167,28 +167,24 @@
      * Retrieve an environment variable's value or if it's not found, return the
      * provided default value.
      *
-     * @param $varname Environment variable name
+     * @param $varname       Environment variable name
      * @param $default_value Default value to return if necessary
-     * @param $type Type of value to return
+     * @param $type          Type of value to return
      *
      * @return Value of the environment variable or default if not found.
      */
     private function getenv_default($varname, $default_value, $type = null)
     {
-        $_ = getenv($varname);
+        $value = getenv($varname);
 
-        if ($_ === false) {
-            $_ = $default_value;
+        if ($value === false) {
+            $value = $default_value;
         }
         else {
-            if (is_null($type)) {
-                $type = gettype($default_value);
-            }
-
-            $_ = $this->parse_env($_, $type);
+            $value = $this->parse_env($value, $type ?: gettype($default_value));
         }
 
-        return $_;
+        return $value;
     }
 
     /**
@@ -206,8 +202,7 @@
         // load main config file
         if (!$this->load_from_file('config.inc.php')) {
             // Old configuration files
-            if (!$this->load_from_file('main.inc.php') ||
-                !$this->load_from_file('db.inc.php')) {
+            if (!$this->load_from_file('main.inc.php') || !$this->load_from_file('db.inc.php')) {
                 $this->errors[] = 'config.inc.php was not found.';
             }
             else if (rand(1,100) == 10) {  // log warning on every 100th request (average)
@@ -229,8 +224,9 @@
         }
 
         // larry is the new default skin :-)
-        if ($this->prop['skin'] == 'default')
+        if ($this->prop['skin'] == 'default') {
             $this->prop['skin'] = self::DEFAULT_SKIN;
+        }
 
         // fix paths
         foreach (array('log_dir' => 'logs', 'temp_dir' => 'temp') as $key => $dir) {
@@ -313,7 +309,7 @@
 
         foreach ($this->resolve_paths($file) as $fpath) {
             if ($fpath && is_file($fpath) && is_readable($fpath)) {
-                // use output buffering, we don't need any output here 
+                // use output buffering, we don't need any output here
                 ob_start();
                 include($fpath);
                 ob_end_clean();
@@ -352,8 +348,9 @@
             // check if <file>-env.ini exists
             if ($realpath && $use_env && !empty($this->env)) {
                 $envfile = preg_replace('/\.(inc.php)$/', '-' . $this->env . '.\\1', $realpath);
-                if (is_file($envfile))
+                if (is_file($envfile)) {
                     $realpath = $envfile;
+                }
             }
 
             if ($realpath) {
@@ -386,8 +383,7 @@
         }
 
         $result = $this->getenv_default('ROUNDCUBE_' . strtoupper($name), $result);
-
-        $rcube = rcube::get_instance();
+        $rcube  = rcube::get_instance();
 
         if ($name == 'timezone') {
             if (empty($result) || $result == 'auto') {
@@ -395,10 +391,12 @@
             }
         }
         else if ($name == 'client_mimetypes') {
-            if ($result == null && $def == null)
+            if (!$result && !$def) {
                 $result = 'text/plain,text/html,text/xml,image/jpeg,image/gif,image/png,image/bmp,image/tiff,application/x-javascript,application/pdf,application/x-shockwave-flash';
-            if ($result && is_string($result))
+            }
+            if ($result && is_string($result)) {
                 $result = explode(',', $result);
+            }
         }
 
         $plugin = $rcube->plugins->exec_hook('config_get', array(
@@ -500,12 +498,13 @@
      * Return requested DES crypto key.
      *
      * @param string $key Crypto key name
+     *
      * @return string Crypto key
      */
     public function get_crypto_key($key)
     {
         // Bomb out if the requested key does not exist
-        if (!array_key_exists($key, $this->prop)) {
+        if (!array_key_exists($key, $this->prop) || empty($this->prop[$key])) {
             rcube::raise_error(array(
                 'code' => 500, 'type' => 'php',
                 'file' => __FILE__, 'line' => __LINE__,
@@ -513,18 +512,17 @@
             ), true, true);
         }
 
-        $key = $this->prop[$key];
+        return $this->prop[$key];
+    }
 
-        // Bomb out if the configured key is not exactly 24 bytes long
-        if (strlen($key) != 24) {
-            rcube::raise_error(array(
-                'code' => 500, 'type' => 'php',
-                'file' => __FILE__, 'line' => __LINE__,
-                'message' => "Configured crypto key '$key' is not exactly 24 bytes long"
-            ), true, true);
-        }
-
-        return $key;
+    /**
+     * Return configured crypto method.
+     *
+     * @return string Crypto method
+     */
+    public function get_crypto_method()
+    {
+        return $this->get('cipher_method') ?: 'DES-EDE3-CBC';
     }
 
     /**
@@ -572,8 +570,9 @@
         $domain = $host;
 
         if (is_array($this->prop['mail_domain'])) {
-            if (isset($this->prop['mail_domain'][$host]))
+            if (isset($this->prop['mail_domain'][$host])) {
                 $domain = $this->prop['mail_domain'][$host];
+            }
         }
         else if (!empty($this->prop['mail_domain'])) {
             $domain = rcube_utils::parse_host($this->prop['mail_domain']);
@@ -683,7 +682,6 @@
              '180' => "Europe/Moscow",
              '210' => "Asia/Tehran",
              '240' => "Asia/Dubai",
-             '300' => "Asia/Karachi",
              '270' => "Asia/Kabul",
              '300' => "Asia/Karachi",
              '330' => "Asia/Kolkata",

--
Gitblit v1.9.1