[icinga-checkins] icinga.org: icingaweb2/bugfix/ zero-width-space-characters-may-destroy-links-in-plugin-output-11796: PluginOutput: add doc

git at icinga.org git at icinga.org
Fri May 20 13:12:59 CEST 2016


Module: icingaweb2
Branch: bugfix/zero-width-space-characters-may-destroy-links-in-plugin-output-11796
Commit: 55bb11e21fbc5660e790e41eddac55ea49a78c4b
URL:    https://git.icinga.org/?p=icingaweb2.git;a=commit;h=55bb11e21fbc5660e790e41eddac55ea49a78c4b

Author: Alexander A. Klimov <alexander.klimov at netways.de>
Date:   Fri May 20 12:48:50 2016 +0200

PluginOutput: add doc

refs #11796

---

 .../application/views/helpers/PluginOutput.php     |   46 ++++++++++++++++++++
 1 file changed, 46 insertions(+)

diff --git a/modules/monitoring/application/views/helpers/PluginOutput.php b/modules/monitoring/application/views/helpers/PluginOutput.php
index b78417d..7bb1cc4 100644
--- a/modules/monitoring/application/views/helpers/PluginOutput.php
+++ b/modules/monitoring/application/views/helpers/PluginOutput.php
@@ -1,10 +1,23 @@
 <?php
 /* Icinga Web 2 | (c) 2013 Icinga Development Team | GPLv2+ */
 
+/**
+ * Plugin output renderer
+ */
 class Zend_View_Helper_PluginOutput extends Zend_View_Helper_Abstract
 {
+    /**
+     * The return value of getPurifier()
+     *
+     * @var HTMLPurifier
+     */
     protected static $purifier;
 
+    /**
+     * Patterns to be replaced in plain text plugin output
+     *
+     * @var array
+     */
     protected static $txtPatterns = array(
         '~\\\n~',
         '~\\\t~',
@@ -16,6 +29,11 @@ class Zend_View_Helper_PluginOutput extends Zend_View_Helper_Abstract
         '~\@{6,}~'
     );
 
+    /**
+     * Replacements for $txtPatterns
+     *
+     * @var array
+     */
     protected static $txtReplacements = array(
         "\n",
         "\t",
@@ -28,15 +46,30 @@ class Zend_View_Helper_PluginOutput extends Zend_View_Helper_Abstract
     );
 
     /**
+     * The character ​
+     *
      * @var string
      */
     protected $zeroWidthSpace;
 
+    /**
+     * Create a new Zend_View_Helper_PluginOutput
+     */
     public function __construct()
     {
+        // This is actually not required as the value is constant,
+        // but as its (visual) length is 0, it's likely to be mixed up with the empty string.
         $this->zeroWidthSpace = html_entity_decode('​', ENT_NOQUOTES, 'UTF-8');
     }
 
+    /**
+     * Render plugin output
+     *
+     * @param   string  $output
+     * @param   bool    $raw
+     *
+     * @return  string
+     */
     public function pluginOutput($output, $raw = false)
     {
         if (empty($output)) {
@@ -76,6 +109,14 @@ class Zend_View_Helper_PluginOutput extends Zend_View_Helper_Abstract
         return $output;
     }
 
+    /**
+     * Replace classic Icinga CGI links with Icinga Web 2 links and
+     * add zero width space to make wrapping easier for the user agent
+     *
+     * @param   string  $html
+     *
+     * @return  string
+     */
     protected function fixLinksAndWrapping($html)
     {
 
@@ -106,6 +147,11 @@ class Zend_View_Helper_PluginOutput extends Zend_View_Helper_Abstract
         return substr($dom->saveHTML(), 5, -7);
     }
 
+    /**
+     * Initialize and return self::$purifier
+     *
+     * @return HTMLPurifier
+     */
     protected function getPurifier()
     {
         if (self::$purifier === null) {



More information about the icinga-checkins mailing list