From 6c61b8c7bfeaedfca53832c16b00b81f85ca5186 Mon Sep 17 00:00:00 2001 From: Ton Voon Date: Fri, 27 Oct 2006 15:37:31 +0000 Subject: More edge testcases. Allow anything if ends with a . as long as correct characters git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1531 f882894a-f735-0410-b71e-b25c423dba1c --- plugins-scripts/utils.pm.in | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'plugins-scripts/utils.pm.in') diff --git a/plugins-scripts/utils.pm.in b/plugins-scripts/utils.pm.in index e2458359..8449b544 100644 --- a/plugins-scripts/utils.pm.in +++ b/plugins-scripts/utils.pm.in @@ -53,9 +53,16 @@ sub usage { sub is_hostname { my $host1 = shift; - if ($host1 && $host1 =~ m/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|[a-zA-Z0-9][-a-zA-Z0-9]+(\.[a-zA-Z0-9][-a-zA-Z0-9]+)*)$/) { + return 0 unless defined $host1; + if ($host1 =~ m/^[\d\.]+$/ && $host1 !~ /\.$/) { + if ($host1 =~ m/^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/) { + return 1; + } else { + return 0; + } + } elsif ($host1 =~ m/^[a-zA-Z0-9][-a-zA-Z0-9]+(\.[a-zA-Z0-9][-a-zA-Z0-9]+)*\.?$/) { return 1; - }else{ + } else { return 0; } } -- cgit v1.2.3