Fixed warnings and problem with multibyte characters on WebServer.

This commit is contained in:
Junichi Satoh 2021-08-17 16:01:35 +09:00
parent e75db62389
commit ba5e78f398
2 changed files with 7 additions and 6 deletions

View File

@ -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));

View File

@ -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