From 6f5dc07696ddbe2a5289024afa2fb3ea7afbe3b9 Mon Sep 17 00:00:00 2001 From: rudolfkoenig <> Date: Thu, 29 Dec 2022 16:23:57 +0000 Subject: [PATCH] HttpUtils.pm: fix port with encoding=unicode (Forum #131207) git-svn-id: https://svn.fhem.de/fhem/trunk@26928 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/HttpUtils.pm | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/fhem/FHEM/HttpUtils.pm b/fhem/FHEM/HttpUtils.pm index 02cf60b45..d903e8845 100644 --- a/fhem/FHEM/HttpUtils.pm +++ b/fhem/FHEM/HttpUtils.pm @@ -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) {