From e8f76f8e9d99754fe5e3e97470bd1297abc56fc4 Mon Sep 17 00:00:00 2001 From: hkosaka Date: Tue, 17 Jun 2014 02:18:49 +0000 Subject: [PATCH] 2014-06-17 Hirofumi Kosaka * lib/PandoraFMS/PluginServer.pm: Fixed to handle plugin's output that includes multibyte character string. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@10207 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_server/ChangeLog | 5 +++++ pandora_server/lib/PandoraFMS/PluginServer.pm | 10 ++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index c6321b562a..95ac621390 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,8 @@ +2014-06-17 Hirofumi Kosaka + + * lib/PandoraFMS/PluginServer.pm: Fixed to handle plugin's + output that includes multibyte character string. + 2014-05-15 Junichi Satoh * util/pandora_manage.pl: Fixed typo. diff --git a/pandora_server/lib/PandoraFMS/PluginServer.pm b/pandora_server/lib/PandoraFMS/PluginServer.pm index 429812fbc8..7a0651954a 100644 --- a/pandora_server/lib/PandoraFMS/PluginServer.pm +++ b/pandora_server/lib/PandoraFMS/PluginServer.pm @@ -27,7 +27,7 @@ use Thread::Semaphore; use POSIX qw(strftime); use HTML::Entities; use JSON qw(decode_json); -use Encode qw(encode_utf8); +use Encode qw(encode_utf8 decode_utf8); # Default lib dir for RPM and DEB packages use lib '/usr/lib/perl5'; @@ -232,11 +232,9 @@ sub data_consumer ($$) { $module_data = `$command`; }; - # Empty ? - if (!defined($module_data)){ - $module_data = ""; - } - + # Empty ? or handle it as 'utf8' string + $module_data = ( !defined($module_data) ? "" : decode_utf8($module_data) ); + # Clean blank spaces and carriage return from start and end of the data $module_data =~ s/^[\s|\n|\r]*//; $module_data =~ s/[\s|\n|\r]*$//;