Subject: | Valid IPv6 range is rejected |
Date: | Thu, 16 Jan 2014 14:27:23 -0600 |
To: | bug-Net-IP [...] rt.cpan.org |
From: | Phil King <phil [...] cpanel.net> |
The validation rules examine an IPv6 address, looking for a maximum of 7 colons. I have encountered a specific case, when describing a /112 range, where 8 colons is legal:
e.g. 2001:db8:3:4:5:6:7::/112
Here is a proposed solution:
# Count octets
my $n = ( $ip =~ tr/:/:/ );
- return 0 unless ( $n > 0 and $n < 8 );
+ return 0 unless ( $n > 0 and $n < ( $ip =~ /::$/ ? 9 : 8 ) );
This address is legal, at least according to this utility:
https://www.ultratools.com/tools/ipv6CIDRToRangeResult?ipAddress=2001%3Adb8%3A3%3A4%3A5%3A6%3A7%3A%3A%2F112
---
Phil King
Product Owner
The Angry Llama team