[2/2] ipblocklist.cgi: Fix settings checkbox handling

Message ID 20230307121735.6485-2-stefan.schantl@ipfire.org
State Accepted
Commit 0450dce6f6eb02fc539c0f0d0ccc01a281dcad58
Headers
Series [1/2] firewall: Silence warnings if blocklist logging is not set. |

Commit Message

Stefan Schantl March 7, 2023, 12:17 p.m. UTC
  Checkboxes does not submit any values if they are not checked.
Default them to "off" in such a case.

This fixes the issue not beeing able to disable the logging.

Fixes #12979.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
---
 html/cgi-bin/ipblocklist.cgi | 4 ++++
 1 file changed, 4 insertions(+)
  

Comments

Adolf Belka March 7, 2023, 7:01 p.m. UTC | #1
Reviewed-by: Adolf Belka <adolf.belka@ipfire.org>

On 07/03/2023 13:17, Stefan Schantl wrote:
> Checkboxes does not submit any values if they are not checked.
> Default them to "off" in such a case.
>
> This fixes the issue not beeing able to disable the logging.
>
> Fixes #12979.
>
> Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
> ---
> html/cgi-bin/ipblocklist.cgi | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/html/cgi-bin/ipblocklist.cgi b/html/cgi-bin/ipblocklist.cgi
> index bb438129c..b79eb155f 100644
> --- a/html/cgi-bin/ipblocklist.cgi
> +++ b/html/cgi-bin/ipblocklist.cgi
> @@ -72,6 +72,10 @@ my @blocklists = &IPblocklist::get_blocklists();
> # Process actions
> if ($cgiparams{'ACTION'} eq "$Lang::tr{'save'}") {
> + # Assign checkbox values, in case they are not checked.
> + $cgiparams{'ENABLE'} = "off" unless($cgiparams{'ENABLE'});
> + $cgiparams{'LOGGING'} = "off" unless($cgiparams{'LOGGING'});
> +
> # Array to store if blocklists are missing on the system
> # and needs to be downloaded first.
> my @missing_blocklists = ();
  

Patch

diff --git a/html/cgi-bin/ipblocklist.cgi b/html/cgi-bin/ipblocklist.cgi
index bb438129c..b79eb155f 100644
--- a/html/cgi-bin/ipblocklist.cgi
+++ b/html/cgi-bin/ipblocklist.cgi
@@ -72,6 +72,10 @@  my @blocklists = &IPblocklist::get_blocklists();
 
 # Process actions
 if ($cgiparams{'ACTION'} eq "$Lang::tr{'save'}") {
+	# Assign checkbox values, in case they are not checked.
+	$cgiparams{'ENABLE'} = "off" unless($cgiparams{'ENABLE'});
+	$cgiparams{'LOGGING'} = "off" unless($cgiparams{'LOGGING'});
+
 	# Array to store if blocklists are missing on the system
 	# and needs to be downloaded first.
 	my @missing_blocklists = ();