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

---
 plugins/help/help.php |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/plugins/help/help.php b/plugins/help/help.php
index d71cd0e..029ab97 100644
--- a/plugins/help/help.php
+++ b/plugins/help/help.php
@@ -34,6 +34,7 @@
         $this->register_action('license', array($this, 'action'));
 
         $this->add_hook('startup', array($this, 'startup'));
+        $this->add_hook('error_page', array($this, 'error_page'));
     }
 
     function startup($args)
@@ -140,13 +141,24 @@
         return $rcmail->output->frame($attrib);
     }
 
+    function error_page($args)
+    {
+        $rcmail = rcmail::get_instance();
+
+        if ($args['code'] == 403 && $rcmail->request_status == rcube::REQUEST_ERROR_URL && ($url = $rcmail->config->get('help_csrf_info'))) {
+            $args['text'] .= '<p>' . html::a(array('href' => $url, 'target' => '_blank'), $this->gettext('csrfinfo')) . '</p>';
+        }
+
+        return $args;
+    }
 
     private function resolve_language($path)
     {
         // resolve language placeholder
-        $rcmail = rcmail::get_instance();
+        $rcmail  = rcmail::get_instance();
         $langmap = $rcmail->config->get('help_language_map', array('*' => 'en_US'));
-        $lang = !empty($langmap[$_SESSION['language']]) ? $langmap[$_SESSION['language']] : $langmap['*'];
+        $lang    = $langmap[$_SESSION['language']] ?: $langmap['*'];
+
         return str_replace('%l', $lang, $path);
     }
 }

--
Gitblit v1.9.1