2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-10 09:16:53 +00:00

fhem.pl: fix JSON decoding in utf-8 encoding mode (Forum #128932)

git-svn-id: https://svn.fhem.de/fhem/trunk@26369 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2022-09-02 09:53:39 +00:00
parent b7c536db01
commit 96697248c8

View File

@ -3709,6 +3709,7 @@ EvalSpecials($%)
if(defined($specials{"%EVENT"})) {
foreach my $part (split(" ", $specials{"%EVENT"})) {
$specials{"%EVTPART$idx"} = $part;
last if($idx >= 20);
$idx++;
}
}
@ -5342,7 +5343,10 @@ json2nameValue($;$$$$)
$esc = !$esc;
} elsif($s eq '"' && !$esc) {
my $val = substr($t,1,$off-1);
$val =~ s/\\u([0-9A-F]{4})/chr(hex($1))/gsie; # toJSON reverse
if($val =~ m/\\u([0-9A-F]{4})/i) {
$val =~ s/\\u([0-9A-F]{4})/chr(hex($1))/gsie; # toJSON reverse
$val = Encode::encode("UTF-8", $val) if(!$unicodeEncoding); #128932
}
my %t = ( n =>"\n", '"'=>'"', '\\'=>'\\' );
$val =~ s/\\([n"\\])/$t{$1}/ge;
return (undef, $val, substr($t,$off+1));