From: Stefan Schantl Date: Mon, 14 Jun 2021 19:38:42 +0000 (+0200) Subject: dhcp.cgi: Fix typo and displaying advanced options syntax. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b224a967c78e6a1243a1bf356c18991637345b76;p=people%2Fstevee%2Fipfire-2.x.git dhcp.cgi: Fix typo and displaying advanced options syntax. Signed-off-by: Stefan Schantl --- diff --git a/html/cgi-bin/dhcp.cgi b/html/cgi-bin/dhcp.cgi index 4c9fff8353..f1fbfd2358 100644 --- a/html/cgi-bin/dhcp.cgi +++ b/html/cgi-bin/dhcp.cgi @@ -131,7 +131,7 @@ our @current2 = ; close(FILE); # Open and read-in file which contains the list of allowed advanced options. -open(FILE, $filename3) or die "Could not open $filename3. $!\n" +open(FILE, $filename3) or die "Could not open $filename3. $!\n"; # Grab file content. my @advoptions_list = ; @@ -723,10 +723,19 @@ if ($dhcpsettings{'KEY1'} ne '') { } #search if the 'option' is in the list and print the syntax model -my @opt = grep(/option $dhcpsettings{'ADVOPT_NAME'}/, @advoptions_list); +my $opt; -# Assign array element to variable and remove newlines. -my $opt = chomp(@opt[0]); +# Check if a advanced option name is set. +if ($dhcpsettings{'ADVOPT_NAME'}) { + # Check if the name is part of the list and grab syntax. + my @opt = grep(/option $dhcpsettings{'ADVOPT_NAME'}/, @advoptions_list); + + # Assign array element to variable. + $opt = @opt[0]; + + # Remove newlines. + chomp($opt); +} if ($opt ne '') { $opt =~ s/option $dhcpsettings{'ADVOPT_NAME'}/Syntax:/; # "option xyz abc" => "syntax: abc"