mirror of
https://github.com/webmin/webmin.git
synced 2026-02-03 14:13:29 +00:00
Fail more gracefully if regexp is invalid
This commit is contained in:
@@ -7,10 +7,14 @@ my $re = $_[0]->{'regexp'};
|
|||||||
if ($re ne '') {
|
if ($re ne '') {
|
||||||
# Get output and compare
|
# Get output and compare
|
||||||
my $out = &backquote_logged("($_[0]->{'cmd'}) 2>&1 </dev/null");
|
my $out = &backquote_logged("($_[0]->{'cmd'}) 2>&1 </dev/null");
|
||||||
if ($_[0]->{'remode'} == 0 && $out !~ /$re/) {
|
my $match = eval { $out =~ /$re/ };
|
||||||
|
if ($@) {
|
||||||
|
return { 'up' => -1, 'desc' => $@ };
|
||||||
|
}
|
||||||
|
elsif ($_[0]->{'remode'} == 0 && !$match) {
|
||||||
return { 'up' => 0 };
|
return { 'up' => 0 };
|
||||||
}
|
}
|
||||||
elsif ($_[0]->{'remode'} == 1 && $out =~ /$re/) {
|
elsif ($_[0]->{'remode'} == 1 && $match) {
|
||||||
return { 'up' => 0 };
|
return { 'up' => 0 };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user