From 984f14bdc4e1663200d286f98935158884366fa4 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Tue, 7 Jan 2020 14:41:13 +0000 Subject: [PATCH] dns.cgi: Fix handling of WARNINGs from kdig There might be multiple warnings which must all be shown to the user. Signed-off-by: Stefan Schantl Signed-off-by: Michael Tremer --- html/cgi-bin/dns.cgi | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/html/cgi-bin/dns.cgi b/html/cgi-bin/dns.cgi index a66b1ed08d..a878f1786b 100755 --- a/html/cgi-bin/dns.cgi +++ b/html/cgi-bin/dns.cgi @@ -795,10 +795,6 @@ sub check_nameserver($$$$) { my $output = join("", @output); my $status = 0; - if ($output =~ m/WARNING: (.*)/) { - return $1; - - } if ($output =~ m/status: (\w+)/) { $status = ($1 eq "NOERROR"); @@ -806,6 +802,18 @@ sub check_nameserver($$$$) { if (!$status) { return -1; } + } else { + my $warning; + + while ($output =~ m/WARNING: (.*)/g) { + # Add the current grabbed warning to the warning string. + $warning .= "$1\; "; + } + + # Return the warning string, if we grabbed at least one. + if ($warning) { + return $warning; + } } my @flags = (); -- 2.39.2