diff --git a/pandora_server/lib/PandoraFMS/Tools.pm b/pandora_server/lib/PandoraFMS/Tools.pm index a6bc59c765..2b6c79f422 100755 --- a/pandora_server/lib/PandoraFMS/Tools.pm +++ b/pandora_server/lib/PandoraFMS/Tools.pm @@ -378,15 +378,20 @@ our $THRRUN :shared = 1; sub read_file($$) { my ($path, $enc) = @_; + my $_FILE; + if ( $enc eq '' ) { - $enc = 'utf8'; + if( !open($_FILE, "<", $path) ) { + # failed to open, return undef + return undef; + } + } else { + if( !open($_FILE, "<:encoding($enc)", $path) ) { + # failed to open, return undef + return undef; + } } - my $_FILE; - if( !open($_FILE, "<:encoding($enc)", $path) ) { - # failed to open, return undef - return undef; - } # Slurp configuration file content. my $content = do { local $/; <$_FILE> };