From 5410fcbc452fe06a4a7de3789ad83f5a9b4a4660 Mon Sep 17 00:00:00 2001 From: Stefan Schantl Date: Mon, 14 Jun 2021 21:38:42 +0200 Subject: [PATCH] dhcp.cgi: Fix typo and displaying advanced options syntax. Signed-off-by: Stefan Schantl --- html/cgi-bin/dhcp.cgi | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) 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" -- 2.39.5