dns.cgi: Fixes bug#12395 - German umlauts not correctly displayed in remarks

- If Freifunk München e.V. is entered as a remark it gets converted to
   Freifunk München e.V.
- This is because cleanhtml is used on the UTF-8 remark text before saving it to the file
   and the HTML::Entities::encode_entities command that is run on that remark text does
   not work with UTF-8 text.
- If the UTF-8 text in the remark is decoded before running through the cleanhtml command
   then the characters with diacritical marks are correctly shown.
- Have tested out the fix on a remark with a range of different characters with
   diacritical marks and all of the ones tested were displayed correctly with the fix while
   in the original form they were mangled.

Fixes: Bug#12395
Tested-by: Adolf Belka <adolf.belka@ipfire.org>
Signed-off-by: Adolf Belka <adolf.belka@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
This commit is contained in:
Adolf Belka
2024-03-11 13:19:09 +01:00
committed by Michael Tremer
parent 5a7342fc28
commit 716b8fb503

View File

@@ -142,6 +142,13 @@ if (($cgiparams{'SERVERS'} eq $Lang::tr{'save'}) || ($cgiparams{'SERVERS'} eq $L
# Go further if there was no error.
if ( ! $errormessage) {
# Check if a remark has been entered.
# decode the UTF-8 text so that characters with diacritical marks such as
# umlauts are treated correctly by the following cleanhtml command
$cgiparams{'REMARK'} = decode("UTF-8", $cgiparams{'REMARK'});
# run the REMARK text through cleanhtml to ensure all unsafe html characters
# are correctly encoded to their html entities
$cgiparams{'REMARK'} = &Header::cleanhtml($cgiparams{'REMARK'});
my %dns_servers = ();