From ba5e78f398a5472c441368968492c9e59579ff10 Mon Sep 17 00:00:00 2001 From: Junichi Satoh Date: Tue, 17 Aug 2021 16:01:35 +0900 Subject: [PATCH] Fixed warnings and problem with multibyte characters on WebServer. --- pandora_server/lib/PandoraFMS/Goliat/GoliatTools.pm | 9 ++++----- pandora_server/lib/PandoraFMS/WebServer.pm | 4 +++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/pandora_server/lib/PandoraFMS/Goliat/GoliatTools.pm b/pandora_server/lib/PandoraFMS/Goliat/GoliatTools.pm index 2c320477dc..c2d45c946d 100755 --- a/pandora_server/lib/PandoraFMS/Goliat/GoliatTools.pm +++ b/pandora_server/lib/PandoraFMS/Goliat/GoliatTools.pm @@ -83,7 +83,7 @@ sub g_unicode { while ($pos < $len ) { my $item; $item = substr($config_word,$pos,1); - $output = $output.$config_char.decToHex(ord($item)); + $output = $output.$config_char.g_decToHex(ord($item)); $pos++; } $config_word = $output; @@ -99,10 +99,10 @@ sub g_trash_unicode { my $config_depth = $_[0]; my $config_char="%"; my $a; - my $output; + my $output = ""; for ($a=0;$a<$config_depth;$a++){ - $output = $output.$config_char.decToHex(int(rand(25)+97)); + $output = $output.$config_char.g_decToHex(int(rand(25)+97)); } return $output } @@ -113,9 +113,8 @@ sub g_trash_unicode { sub g_trash_ascii { my $config_depth = $_[0]; - my $config_char="%"; my $a; - my $output; + my $output = ""; for ($a=0;$a<$config_depth;$a++){ $output = $output.chr(int(rand(25)+97)); diff --git a/pandora_server/lib/PandoraFMS/WebServer.pm b/pandora_server/lib/PandoraFMS/WebServer.pm index 7906b22691..776ef20456 100644 --- a/pandora_server/lib/PandoraFMS/WebServer.pm +++ b/pandora_server/lib/PandoraFMS/WebServer.pm @@ -28,6 +28,8 @@ use File::Temp qw(tempfile); use HTML::Entities; use POSIX qw(strftime); +use Encode; + # Default lib dir for RPM and DEB packages use lib '/usr/lib/perl5'; @@ -207,7 +209,7 @@ sub data_consumer ($$) { $task = subst_alert_macros ($task, \%macros); # Goliat has some trouble parsing conf files without the newlines - $fh->print ("\n\n" . $task . "\n\n"); + $fh->print ("\n\n" . encode_utf8($task) . "\n\n"); close ($fh); # Global vars needed by Goliat