Message ID | 20240313221212.2653062-1-adolf.belka@ipfire.org |
---|---|
State | Staged |
Commit | cd7a901109751cfa28b7cae01e04192aa17232b4 |
Headers |
Return-Path: <development-bounces@lists.ipfire.org> Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4Tw4WF5dR3z3wkd for <patchwork@web04.haj.ipfire.org>; Wed, 13 Mar 2024 22:12:25 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4Tw4WC06sjzZ8; Wed, 13 Mar 2024 22:12:23 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4Tw4WB5pDqz32P8; Wed, 13 Mar 2024 22:12:22 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4Tw4W8148nz2ygN for <development@lists.ipfire.org>; Wed, 13 Mar 2024 22:12:20 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4Tw4W72fsZzT1; Wed, 13 Mar 2024 22:12:19 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1710367939; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=e4+jSsVzY03GjqOdZebcN6fGSoeRaBb7sjRNSTBNZgc=; b=bGNUwtCqpRC43IaOLjRI1qit4EZ3y8RON04YWpJcoEy5EHdETyrne67QFiNi/zi0ttJS// BFsW4IQLVy0PpABw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1710367939; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=e4+jSsVzY03GjqOdZebcN6fGSoeRaBb7sjRNSTBNZgc=; b=p2kBGae+td1EP3n+jrKfj08njXJPsBYdNLfXzBpc7zTVUfZPNBn8Dt7fwWL5I5nq/sC5fo 7ktT6jMBJMTYiFxIhPcOtZW7vqqR7WjOTz9gNhLyEp71BY7SeItvdOznbIEZnGiD0nBg/G z4gK2ZF0X0T8fPHJiVEMKNJzLuIT8/tcJbf7k9o4FQULGx5w8kCe3cV5i5w65YG8D7JOKt M+NGJ22At0PfroZqU3WLY1ohJ6P0tt9OqOIc5jd9gESV5/7XWMXSykNkjYXX0bSWKrwryZ ONqMikqwqLq9rnc33dTKk9afyaPPqDcEgqeWQWQ6JhLKebIWAwEwQtXodJ8OXg== From: Adolf Belka <adolf.belka@ipfire.org> To: development@lists.ipfire.org Subject: [PATCH] dns.cgi: Add use Encode + encode back to UTF-8 Date: Wed, 13 Mar 2024 23:12:12 +0100 Message-ID: <20240313221212.2653062-1-adolf.belka@ipfire.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: J6HFQQ62NQ5ZWZXYJODFZG5W2EARCFWF X-Message-ID-Hash: J6HFQQ62NQ5ZWZXYJODFZG5W2EARCFWF X-MailFrom: adolf.belka@ipfire.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: IPFire development talk <development.lists.ipfire.org> Archived-At: <https://lists.ipfire.org/hyperkitty/list/development@lists.ipfire.org/message/J6HFQQ62NQ5ZWZXYJODFZG5W2EARCFWF/> List-Archive: <https://lists.ipfire.org/hyperkitty/list/development@lists.ipfire.org/> List-Help: <mailto:development-request@lists.ipfire.org?subject=help> List-Owner: <mailto:development-owner@lists.ipfire.org> List-Post: <mailto:development@lists.ipfire.org> List-Subscribe: <mailto:development-join@lists.ipfire.org> List-Unsubscribe: <mailto:development-leave@lists.ipfire.org> |
Series |
dns.cgi: Add use Encode + encode back to UTF-8
|
|
Commit Message
Adolf Belka
March 13, 2024, 10:12 p.m. UTC
- use Encode was missed out in the previous patch for dns.cgi This would mean that the decode from UTF-8 would fail. I had tested the previous change but forgot to copy across the use Encode line when I created the patch. - This patch adds an encode back to UTF-8 after running the cleanhtml command. This way the text is decoded from UTF-8 so that the cleanhtml command works correctly on umlauted characters and then is encoded back to UTF-8 so that all text in the cgi page is UTF-8. Tested-by: Adolf Belka <adolf.belka@ipfire.org> Signed-off-by: Adolf Belka <adolf.belka@ipfire.org> --- html/cgi-bin/dns.cgi | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
Comments
Hi Michael, I saw that this patch had been merged but then saw that you had added a patch to remove extraneous whitespace. I thought at first that I had added a blank line also to the dns.cgi file. Then looked at the patch and at first did not understand it because it looked like it had deleted a line and then added it back in. Eventually figured it out :-) My editor had automatic indentation turned on and so it added in the tabs to get to the start of the previous line. I found that on some lines and removed it but missed it on that last line. I have now turned off the automatic indentation so that a blank line will in fact stay blank with no spaces. Sorry about that. Regards, Adolf. On 13/03/2024 23:12, Adolf Belka wrote: > - use Encode was missed out in the previous patch for dns.cgi This would mean that the > decode from UTF-8 would fail. I had tested the previous change but forgot to copy across > the use Encode line when I created the patch. > - This patch adds an encode back to UTF-8 after running the cleanhtml command. This way > the text is decoded from UTF-8 so that the cleanhtml command works correctly on > umlauted characters and then is encoded back to UTF-8 so that all text in the cgi page > is UTF-8. > > Tested-by: Adolf Belka <adolf.belka@ipfire.org> > Signed-off-by: Adolf Belka <adolf.belka@ipfire.org> > --- > html/cgi-bin/dns.cgi | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/html/cgi-bin/dns.cgi b/html/cgi-bin/dns.cgi > index eb6f908d5..c864c127d 100644 > --- a/html/cgi-bin/dns.cgi > +++ b/html/cgi-bin/dns.cgi > @@ -2,7 +2,7 @@ > ############################################################################### > # # > # IPFire.org - A linux based firewall # > -# Copyright (C) 2020 IPFire Development Team # > +# Copyright (C) 2005-2024 IPFire Team <info@ipfire.org> # > # # > # This program is free software: you can redistribute it and/or modify # > # it under the terms of the GNU General Public License as published by # > @@ -21,6 +21,7 @@ > > use strict; > use IO::Socket; > +use Encode; > > # enable only the following on debugging purpose > #use warnings; > @@ -151,6 +152,9 @@ if (($cgiparams{'SERVERS'} eq $Lang::tr{'save'}) || ($cgiparams{'SERVERS'} eq $L > # are correctly encoded to their html entities > $cgiparams{'REMARK'} = &Header::cleanhtml($cgiparams{'REMARK'}); > > + # encode the text back to UTF-8 after running the cleanhtml command > + $cgiparams{'REMARK'} = encode("UTF-8", $cgiparams{'REMARK'}); > + > my %dns_servers = (); > my $id; > my $status;
Hello Adolf, Yes, editors sometimes have odd default settings. I don’t know why, because I never feel like they would be the right thing for anyone. However, we generally don’t want lines with just whitespace. We just want an empty line. “git show” shows any whitespace like that in bright red and when you apply a patch it shows a warning. I am not sure if we need to write down some guidelines anywhere for this though. Everyone’s editor is different anyways. -Michael > On 14 Mar 2024, at 11:13, Adolf Belka <adolf.belka@ipfire.org> wrote: > > Hi Michael, > > I saw that this patch had been merged but then saw that you had added a patch to remove extraneous whitespace. I thought at first that I had added a blank line also to the dns.cgi file. Then looked at the patch and at first did not understand it because it looked like it had deleted a line and then added it back in. > > Eventually figured it out :-) My editor had automatic indentation turned on and so it added in the tabs to get to the start of the previous line. I found that on some lines and removed it but missed it on that last line. > > I have now turned off the automatic indentation so that a blank line will in fact stay blank with no spaces. > > Sorry about that. > > Regards, > Adolf. > > On 13/03/2024 23:12, Adolf Belka wrote: >> - use Encode was missed out in the previous patch for dns.cgi This would mean that the >> decode from UTF-8 would fail. I had tested the previous change but forgot to copy across >> the use Encode line when I created the patch. >> - This patch adds an encode back to UTF-8 after running the cleanhtml command. This way >> the text is decoded from UTF-8 so that the cleanhtml command works correctly on >> umlauted characters and then is encoded back to UTF-8 so that all text in the cgi page >> is UTF-8. >> Tested-by: Adolf Belka <adolf.belka@ipfire.org> >> Signed-off-by: Adolf Belka <adolf.belka@ipfire.org> >> --- >> html/cgi-bin/dns.cgi | 6 +++++- >> 1 file changed, 5 insertions(+), 1 deletion(-) >> diff --git a/html/cgi-bin/dns.cgi b/html/cgi-bin/dns.cgi >> index eb6f908d5..c864c127d 100644 >> --- a/html/cgi-bin/dns.cgi >> +++ b/html/cgi-bin/dns.cgi >> @@ -2,7 +2,7 @@ >> ############################################################################### >> # # >> # IPFire.org - A linux based firewall # >> -# Copyright (C) 2020 IPFire Development Team # >> +# Copyright (C) 2005-2024 IPFire Team <info@ipfire.org> # >> # # >> # This program is free software: you can redistribute it and/or modify # >> # it under the terms of the GNU General Public License as published by # >> @@ -21,6 +21,7 @@ >> use strict; >> use IO::Socket; >> +use Encode; >> # enable only the following on debugging purpose >> #use warnings; >> @@ -151,6 +152,9 @@ if (($cgiparams{'SERVERS'} eq $Lang::tr{'save'}) || ($cgiparams{'SERVERS'} eq $L >> # are correctly encoded to their html entities >> $cgiparams{'REMARK'} = &Header::cleanhtml($cgiparams{'REMARK'}); >> + # encode the text back to UTF-8 after running the cleanhtml command >> + $cgiparams{'REMARK'} = encode("UTF-8", $cgiparams{'REMARK'}); >> + >> my %dns_servers = (); >> my $id; >> my $status;
diff --git a/html/cgi-bin/dns.cgi b/html/cgi-bin/dns.cgi index eb6f908d5..c864c127d 100644 --- a/html/cgi-bin/dns.cgi +++ b/html/cgi-bin/dns.cgi @@ -2,7 +2,7 @@ ############################################################################### # # # IPFire.org - A linux based firewall # -# Copyright (C) 2020 IPFire Development Team # +# Copyright (C) 2005-2024 IPFire Team <info@ipfire.org> # # # # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # @@ -21,6 +21,7 @@ use strict; use IO::Socket; +use Encode; # enable only the following on debugging purpose #use warnings; @@ -151,6 +152,9 @@ if (($cgiparams{'SERVERS'} eq $Lang::tr{'save'}) || ($cgiparams{'SERVERS'} eq $L # are correctly encoded to their html entities $cgiparams{'REMARK'} = &Header::cleanhtml($cgiparams{'REMARK'}); + # encode the text back to UTF-8 after running the cleanhtml command + $cgiparams{'REMARK'} = encode("UTF-8", $cgiparams{'REMARK'}); + my %dns_servers = (); my $id; my $status;