Implement is_ipv6
in terms of extract_ivp6
This commit is contained in:
parent
ab0a4597ce
commit
5da22a8a69
1 changed files with 3 additions and 3 deletions
|
@ -2347,12 +2347,12 @@ sub extract_ipv4 {
|
||||||
}
|
}
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
## is_ipv6() validates if string is valid IPv6 address
|
## is_ipv6() validates if string is valid IPv6 address with no preceding
|
||||||
|
## or trailing spaces/characters.
|
||||||
######################################################################
|
######################################################################
|
||||||
sub is_ipv6 {
|
sub is_ipv6 {
|
||||||
my ($value) = @_;
|
my ($value) = @_;
|
||||||
# This little gem from http://home.deds.nl/~aeron/regex/
|
return (length($value // '') != 0) && ((extract_ipv6($value) // '') eq $value);
|
||||||
return $value =~ /^(((?=.*(::))(?!.*\3.+\3))\3?|([\dA-F]{1,4}(\3|:\b|$)|\2))(?4){5}((?4){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4})\z/ai;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
Loading…
Reference in a new issue