Title: [opsview] [12908] Plugin output improvements in HH
Revision
12908
Author
dferguson
Date
2013-07-12 12:54:55 +0100 (Fri, 12 Jul 2013)

Log Message

Plugin output improvements in HH

Plugin output has HTML tags escaped in the Hostgroup Hierarchy pages (use markdown instead if it is required)
Plugin output has newlines converted to <BR>'s in the Hostgroup Hierarchy pages

Modified Paths

Modified: trunk/CHANGES
===================================================================
--- trunk/CHANGES	2013-07-12 11:13:56 UTC (rev 12907)
+++ trunk/CHANGES	2013-07-12 11:54:55 UTC (rev 12908)
@@ -20,6 +20,8 @@
     Patch from Nagios Core to improve error message when plugin times out
     Improved SNMP interface speed detection so that speeds that are 0 in ifXSpeed area of SNMP
      will use ifSpeed if possible
+    Plugin output has HTML tags escaped in the Hostgroup Hierarchy pages (use markdown instead if it is required)
+    Plugin output has newlines converted to <BR>'s in the Hostgroup Hierarchy pages
     NOTICES:
     FIXES:
     Fixed CONTACTGROUPLIST environment macro, broken in Nagios 4 upgrade

Modified: trunk/opsview-web/lib/Opsview/Web/View/TT.pm
===================================================================
--- trunk/opsview-web/lib/Opsview/Web/View/TT.pm	2013-07-12 11:13:56 UTC (rev 12907)
+++ trunk/opsview-web/lib/Opsview/Web/View/TT.pm	2013-07-12 11:54:55 UTC (rev 12908)
@@ -52,4 +52,23 @@
     return $m->markdown($s);
 }
 
+# Filter plugin output through a couple of filters to clean it up
+$Template::Filters::FILTERS->{ov_html_encode} = \&ov_html_encode;
+
+sub ov_html_encode {
+    my $s = shift;
+
+    # escape all html tags coming through to the browser so they are not
+    # acted on; users should use markdown instead if they require this
+    # functionality
+    my $filter_html = $Template::Filters::FILTERS->{html};
+    $s = $filter_html->($s);
+
+    # convert all linne breaks to <br's> for multi line output
+    my $filter_html_line_break = $Template::Filters::FILTERS->{html_line_break};
+    $s = $filter_html_line_break->($s);
+
+    return $s;
+}
+
 1;

Modified: trunk/opsview-web/root/status/service
===================================================================
--- trunk/opsview-web/root/status/service	2013-07-12 11:13:56 UTC (rev 12907)
+++ trunk/opsview-web/root/status/service	2013-07-12 11:54:55 UTC (rev 12908)
@@ -161,7 +161,7 @@
     '<td>'; dt_formatter(object.last_check); '</td>';
     '<td>'; object.current_check_attempt; "/"; object.max_check_attempts; '</td>';
     %]<td class="left[% IF object.markdown; " markdown"; END %]">
-    [%- IF object.markdown; object.output | markdown; ELSE; object.output; END -%]
+    [%- IF object.markdown; object.output | markdown; ELSE; object.output | ov_html_encode; END -%]
     </td>
     </tr>
   [%

Modified: trunk/opsview-web/root/viewport/style/group_by_host
===================================================================
--- trunk/opsview-web/root/viewport/style/group_by_host	2013-07-12 11:13:56 UTC (rev 12907)
+++ trunk/opsview-web/root/viewport/style/group_by_host	2013-07-12 11:54:55 UTC (rev 12908)
@@ -124,7 +124,7 @@
         output = object.output | markdown;
         extra_class = " markdown";
       ELSE;
-        output = object.output;
+        output = object.output | ov_html_encode;
       END;
       -%]
       <td class="output[% extra_class %] [% object.state %]">[% output %]</td><td class="acknowledgement [% object.state %]">[%

Modified: trunk/opsview-web/root/viewport/style/group_by_service
===================================================================
--- trunk/opsview-web/root/viewport/style/group_by_service	2013-07-12 11:13:56 UTC (rev 12907)
+++ trunk/opsview-web/root/viewport/style/group_by_service	2013-07-12 11:54:55 UTC (rev 12908)
@@ -50,7 +50,7 @@
     END;
     %]</div></td>
     <td class="output[% IF host.markdown; " markdown"; END %]">
-    [%- IF host.markdown; host.output | markdown; ELSE; host.output; END; -%]
+    [%- IF host.markdown; host.output | markdown; ELSE; host.output | ov_html_encode; END; -%]
     </td>
     <td class="acknowledgement">[%
 

_______________________________________________
Opsview-checkins mailing list
Opsview-checkins@lists.opsview.org
http://lists.opsview.org/lists/listinfo/opsview-checkins

Reply via email to