Title: [opsview] [5289] Fixed UTF8 encoding through Nagios CGIs (OPS-1393)
Revision
5289
Author
charendra
Date
2010-11-02 20:00:53 +0000 (Tue, 02 Nov 2010)

Log Message

Fixed UTF8 encoding through Nagios CGIs (OPS-1393)

Modified Paths


Modified: trunk/CHANGES
===================================================================
--- trunk/CHANGES	2010-11-02 19:37:41 UTC (rev 5288)
+++ trunk/CHANGES	2010-11-02 20:00:53 UTC (rev 5289)
@@ -72,6 +72,7 @@
     MRTG and NMIS configuration is not invoked now, if enable SNMP is off
     Cloning of Enable SNMP now works on a host, using the old Opsview API. However, hosts previously cloned will not have this parameter
       cloned, so will need to be set correctly
+    Fixed UTF8 encoding from Nagios CGIs returned through Opsview
 
     WARNINGS:
     There are some manual post install tasks required. See

Modified: trunk/opsview-web/lib/Opsview/Web/ControllerBase/WrapCGI.pm
===================================================================
--- trunk/opsview-web/lib/Opsview/Web/ControllerBase/WrapCGI.pm	2010-11-02 19:37:41 UTC (rev 5288)
+++ trunk/opsview-web/lib/Opsview/Web/ControllerBase/WrapCGI.pm	2010-11-02 20:00:53 UTC (rev 5289)
@@ -33,6 +33,7 @@
 use HTML::TreeBuilder;
 use URI;
 use URI::Escape;
+use Encode qw/decode/;
 
 # Hack-around because Catalyst::Engine::HTTP goes and changes
 # them to be the remote socket, and FCGI.pm does even dumber things.
@@ -161,7 +162,10 @@
     if ( $c->stash->{div_id} ) {
         $body_data = '<div id="' . $c->stash->{div_id} . '">' . $body_data . "</div>";
     }
-    $c->stash( cgi_output => $body_data );
+
+    # Need to decode output to retain UTF8 characters
+    $c->stash( cgi_output => decode( 'utf8', $body_data ) );
+
     $tree->delete;
 }
 

Modified: trunk/opsview-web/t/910-nagios_cgi.t
===================================================================
--- trunk/opsview-web/t/910-nagios_cgi.t	2010-11-02 19:37:41 UTC (rev 5288)
+++ trunk/opsview-web/t/910-nagios_cgi.t	2010-11-02 20:00:53 UTC (rev 5289)
@@ -3,6 +3,7 @@
 use warnings;
 use strict;
 
+use utf8;
 use Test::WWW::Mechanize;
 use HTTP::Cookies;
 use Sys::Hostname;
@@ -56,6 +57,10 @@
 $ua->form_with_fields("force_check");
 is($ua->value("force_check"), undef, "force_check not set - otherwise could cause problems with distributed setup" );
 
+$ua->get_ok("/cgi-bin/status.cgi?host=賢敦");
+$ua->content_contains('Host: 賢敦', "Check that the UTF8 name is returned in the page header");
+$ua->content_contains(qq{Service Status Details For Host '賢敦'}, "Check that the UTF8 name is returned in the cgis");
+
 $ua->get_ok("/cgi-bin/extinfo.cgi?type=2&host=opsview&service=MySQL");
 $ua->follow_link_ok( { text => "Re-schedule the next check of this service" } );
 $ua->form_with_fields("force_check");

_______________________________________________
Opsview-checkins mailing list
[email protected]
http://lists.opsview.org/lists/listinfo/opsview-checkins

Reply via email to