2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-02-25 16:05:19 +00:00

HttpUtils.pm: fix port with encoding=unicode (Forum #131207)

git-svn-id: https://svn.fhem.de/fhem/trunk@26928 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2022-12-29 16:23:57 +00:00
parent e554a7352f
commit 6f5dc07696

View File

@ -688,6 +688,7 @@ HttpUtils_Connect2($)
if($hash->{auth});
$hdr .= $hash->{header}."\r\n" if($hash->{header});
if(defined($data) && length($data) > 0) {
$data = Encode::encode("UTF-8", $data) if($unicodeEncoding);
$ha->("Content-Length", length($data));
$ha->("Content-Type", "application/x-www-form-urlencoded");
}
@ -736,10 +737,8 @@ HttpUtils_Connect2($)
}
};
$data = "" if(!defined($data));
$data = Encode::decode("UTF-8", $data) if($unicodeEncoding);
$data = $hdr.$data;
$hdr = Encode::encode("UTF-8", $hdr) if($unicodeEncoding); #Tainting/131207
$data = $hdr.(defined($data) ? $data:"");
$hash->{directWriteFn} = sub($) { # Nonblocking write
my $ret = syswrite $hash->{conn}, $data;
if(!defined($ret) || $ret <= 0) {