[icinga-checkins] icinga.org: icinga-web/support/1.11: Revert "LongPluginOutput: Fix missing support of multi line in html"

git at icinga.org git at icinga.org
Thu Jun 26 15:43:15 CEST 2014


Module: icinga-web
Branch: support/1.11
Commit: 97bf45e2b70d30d3d5a6af566b8a2f9993bbe97f
URL:    https://git.icinga.org/?p=icinga-web.git;a=commit;h=97bf45e2b70d30d3d5a6af566b8a2f9993bbe97f

Author: Eric Lippmann <eric.lippmann at netways.de>
Date:   Thu Jun 26 14:20:11 2014 +0200

Revert "LongPluginOutput: Fix missing support of multi line in html"

This reverts commit 14fdf6323dde83ba51d61d29f7ff3ee4b23614f4.

The fix actually fixes nothing for the following reasons:

1) The "Long plugin output" field of a host's or service's detail window already has `\n' replaced with the HTML break tag.
This is because the information is gathered via Icinga Web's API which calls `Api_Result_OutputRewriteModel::rewritePluginOutput()'
in the controller `ApiSearchAction'.
Note that the carriage return `\r' is not taken into accout, but that's not a problem here.

2) Grids do not benefit from `Api_Result_OutputRewriteModel::rewritePluginOutput()' as its not being called. The `nl2br()' should've
helped here. According to http://www.ietf.org/rfc/rfc4627.txt the JSON representation of strings must escape control characters which includes the line feed `\n'
and the carriage return `\r'. So '\n', '\r' and '\r\n' become '\\n', '\\r' and '\\r\\n' respectively making them a textual representation of the control characters.
The `nl2br()' implementation however only replaces the unescaped line feed and carriage return which does of course replace nothing in the above case.

3) Introducing `String::nl2br()' while ExtJS provides `Ext.util.Format.nl2br()' is superfluous.

refs #2653

---

 app/modules/AppKit/config/javascript.xml           |    1 -
 app/modules/AppKit/lib/js/utils/String.js          |   30 --------------------
 .../lib/js/Cronk/grid/renderer/ColumnRenderer.js   |   11 -------
 .../Cronks/Tackle/Information/LongPluginOutput.js  |    1 -
 .../Cronks/Tackle/Information/OutputPanel.js       |   12 --------
 5 files changed, 55 deletions(-)

diff --git a/app/modules/AppKit/config/javascript.xml b/app/modules/AppKit/config/javascript.xml
index 81b87bc..81a48bc 100644
--- a/app/modules/AppKit/config/javascript.xml
+++ b/app/modules/AppKit/config/javascript.xml
@@ -59,7 +59,6 @@
             <ae:parameter>%core.root_dir%/lib/jsgettext/lib/Gettext.js</ae:parameter>
 
             <ae:parameter>%core.module_dir%/AppKit/lib/js/ext-overrides/TreeNodeDontLeak.js</ae:parameter>
-            <ae:parameter>%core.module_dir%/AppKit/lib/js/utils/String.js</ae:parameter>
         </javascript>
 
 <!--
diff --git a/app/modules/AppKit/lib/js/utils/String.js b/app/modules/AppKit/lib/js/utils/String.js
deleted file mode 100644
index 0ea3d3f..0000000
--- a/app/modules/AppKit/lib/js/utils/String.js
+++ /dev/null
@@ -1,30 +0,0 @@
-// {{{ICINGA_LICENSE_CODE}}}
-// -----------------------------------------------------------------------------
-// This file is part of icinga-web.
-//
-// Copyright (c) 2009-present Icinga Developer Team.
-// All rights reserved.
-//
-// icinga-web is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// icinga-web is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with icinga-web.  If not, see <http://www.gnu.org/licenses/>.
-// -----------------------------------------------------------------------------
-// {{{ICINGA_LICENSE_CODE}}}
-
-(function() {
-    "use static";
-
-    String.prototype.nl2br = function() {
-        return (this + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1<br />$2');
-    };
-
-})();
\ No newline at end of file
diff --git a/app/modules/Cronks/lib/js/Cronk/grid/renderer/ColumnRenderer.js b/app/modules/Cronks/lib/js/Cronk/grid/renderer/ColumnRenderer.js
index 373b8c1..1635dc1 100644
--- a/app/modules/Cronks/lib/js/Cronk/grid/renderer/ColumnRenderer.js
+++ b/app/modules/Cronks/lib/js/Cronk/grid/renderer/ColumnRenderer.js
@@ -80,13 +80,6 @@ Ext.ns('Cronk.grid');
     Cronk.grid.ColumnRenderer = {
 
         customColumnPerfdataSanitized: function (cfg) {
-
-            var multiLine = false;
-
-            if (!Ext.isEmpty(cfg.multiLine) && cfg.multiLine) {
-                multiLine = true;
-            }
-
             return function (value, metaData, record, rowIndex, colIndex, store) {
                 if (!value) {
                     return _('no value');
@@ -106,10 +99,6 @@ Ext.ns('Cronk.grid');
 
                 metaData.attr = 'ext:qtip="' + Ext.util.Format.htmlEncode(value) + '"';
 
-                if (multiLine === true) {
-                    value = String(value).nl2br();
-                }
-
                 return value;
             };
         },
diff --git a/app/modules/Cronks/lib/js/Icinga/Cronks/Tackle/Information/LongPluginOutput.js b/app/modules/Cronks/lib/js/Icinga/Cronks/Tackle/Information/LongPluginOutput.js
index 668efc0..8f93846 100644
--- a/app/modules/Cronks/lib/js/Icinga/Cronks/Tackle/Information/LongPluginOutput.js
+++ b/app/modules/Cronks/lib/js/Icinga/Cronks/Tackle/Information/LongPluginOutput.js
@@ -29,7 +29,6 @@ Ext.ns('Icinga.Cronks.Tackle.Information');
     Icinga.Cronks.Tackle.Information.LongPluginOutput = Ext.extend(
         Icinga.Cronks.Tackle.Information.OutputPanel, {
         title: _("Long plugin output"),
-        keepLineBreaksInHTML: true,
         tplField: 'object_long_output'
     });
 
diff --git a/app/modules/Cronks/lib/js/Icinga/Cronks/Tackle/Information/OutputPanel.js b/app/modules/Cronks/lib/js/Icinga/Cronks/Tackle/Information/OutputPanel.js
index 3049216..fbb8026 100644
--- a/app/modules/Cronks/lib/js/Icinga/Cronks/Tackle/Information/OutputPanel.js
+++ b/app/modules/Cronks/lib/js/Icinga/Cronks/Tackle/Information/OutputPanel.js
@@ -28,7 +28,6 @@ Ext.ns('Icinga.Cronks.Tackle.Information');
 
     Icinga.Cronks.Tackle.Information.OutputPanel = Ext.extend(Ext.Panel, {
         autoScroll: true,
-        keepLineBreaksInHTML: false,
         
         constructor: function(c) {
             Icinga.Cronks.Tackle.Information
@@ -49,17 +48,6 @@ Ext.ns('Icinga.Cronks.Tackle.Information');
             
             Icinga.Cronks.Tackle.Information
                 .OutputPanel.superclass.initComponent.call(this);
-        },
-
-        update: function(htmlOrData, loadScripts, cb) {
-            if (!Ext.isEmpty(this.tplField) && this.keepLineBreaksInHTML === true) {
-                if (!Ext.isEmpty(htmlOrData[this.tplField])) {
-                    htmlOrData[this.tplField] = String(htmlOrData[this.tplField]).nl2br();
-                }
-            }
-
-            Icinga.Cronks.Tackle.Information
-                .OutputPanel.superclass.update.call(this, htmlOrData, loadScripts, cb);
         }
     });
 



More information about the icinga-checkins mailing list