2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-02-07 23:09:26 +00:00

HttpUtils.pm: do not crash on onvalid encoding (Forum #138273)

git-svn-id: https://svn.fhem.de/fhem/trunk@28887 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2024-05-19 19:00:14 +00:00
parent 5a63d86cd8
commit c4fa11ebed

View File

@ -1058,7 +1058,10 @@ HttpUtils_ParseAnswer($)
my $encoding = defined($hash->{forceEncoding}) ? $hash->{forceEncoding} :
$hash->{httpheader} =~ m/^Content-Type.*charset=(\S*)/im ? $1 :
'UTF-8';
$ret = Encode::decode($encoding, $ret) if($unicodeEncoding && $encoding);
if($unicodeEncoding && $encoding) {
eval { $ret = Encode::decode($encoding, $ret) };
return $@ if($@);
}
# Debug
Log3 $hash, $hash->{loglevel}+1,