mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2024-12-23 15:40:01 -06:00
Parse zone indices in IPv6 addresses in CheckedIPAddress.
If a zone index is present in an IPv6 address, it is ignored. ticket 2138
This commit is contained in:
parent
52aa008b87
commit
0024024897
@ -97,7 +97,20 @@ class CheckedIPAddress(netaddr.IPAddress):
|
||||
pass
|
||||
else:
|
||||
try:
|
||||
addr = netaddr.IPAddress(addr, flags=self.netaddr_ip_flags)
|
||||
try:
|
||||
addr = netaddr.IPAddress(addr, flags=self.netaddr_ip_flags)
|
||||
except netaddr.AddrFormatError:
|
||||
# netaddr.IPAddress doesn't handle zone indices in textual
|
||||
# IPv6 addresses. Try removing zone index and parse the
|
||||
# address again.
|
||||
if not isinstance(addr, basestring):
|
||||
raise
|
||||
addr, sep, foo = addr.partition('%')
|
||||
if sep != '%':
|
||||
raise
|
||||
addr = netaddr.IPAddress(addr, flags=self.netaddr_ip_flags)
|
||||
if addr.version != 6:
|
||||
raise
|
||||
except ValueError:
|
||||
net = netaddr.IPNetwork(addr, flags=self.netaddr_ip_flags)
|
||||
if not parse_netmask:
|
||||
|
@ -39,6 +39,8 @@ def test_ip_address():
|
||||
addrs = [
|
||||
('10.11.12.13', (10, 11, 12, 13), 8),
|
||||
('10.11.12.13/14', (10, 11, 12, 13), 14),
|
||||
('10.11.12.13%zoneid',),
|
||||
('10.11.12.13%zoneid/14',),
|
||||
('10.11.12.1337',),
|
||||
('10.11.12.13/33',),
|
||||
('127.0.0.1',),
|
||||
@ -50,6 +52,8 @@ def test_ip_address():
|
||||
|
||||
('2001::1', (0x2001, 0, 0, 0, 0, 0, 0, 1), 64),
|
||||
('2001::1/72', (0x2001, 0, 0, 0, 0, 0, 0, 1), 72),
|
||||
('2001::1%zoneid', (0x2001, 0, 0, 0, 0, 0, 0, 1), 64),
|
||||
('2001::1%zoneid/72',),
|
||||
('2001::1beef',),
|
||||
('2001::1/129',),
|
||||
('::1',),
|
||||
|
Loading…
Reference in New Issue
Block a user