From 741c9b8e14b0b83709af51f3208a1840b6667e5d Mon Sep 17 00:00:00 2001 From: rudolfkoenig <> Date: Sun, 20 Feb 2022 18:02:01 +0000 Subject: [PATCH] 01_FHEMWEB.pm: support newlines in attributes for encoding unicode (Forum #126088) git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@25717 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- FHEM/01_FHEMWEB.pm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/FHEM/01_FHEMWEB.pm b/FHEM/01_FHEMWEB.pm index 17c8f38ca..1f8d2b808 100644 --- a/FHEM/01_FHEMWEB.pm +++ b/FHEM/01_FHEMWEB.pm @@ -727,7 +727,7 @@ FW_addToWritebuffer($$@) my ($hash, $txt, $callback, $nolimit, $encoded) = @_; $txt = Encode::encode($hash->{encoding}, $txt) - if(!$encoded && ($unicodeEncoding || + if($hash->{encoding} && !$encoded && ($unicodeEncoding || (utf8::is_utf8($txt) && $txt =~ m/[^\x00-\xFF]/))); if( $hash->{websocket} ) { my $len = length($txt); @@ -1283,7 +1283,10 @@ FW_digestCgi($) next if($pv eq ""); # happens when post forgot to set FW_ME $pv =~ s/\+/ /g; $pv =~ s/%([\dA-F][\dA-F])/chr(hex($1))/ige; - $pv = Encode::decode('UTF-8', $pv) if($unicodeEncoding); + if($unicodeEncoding) { + $pv = Encode::decode('UTF-8', $pv); + $pv =~ s/\x{2424}/\n/g; # revert fhemweb.js hack + } my ($p,$v) = split("=",$pv, 2); $v = "" if(!defined($v));