ipaddr: Handle ipaddress index in network correctly (#57896)

This commit prevents integer indices from being parsed as ip nets

Fixes #57895

Signed-off-by: Tobias Schramm <tobleminer@gmail.com>
pull/58196/head
Tobias 5 years ago committed by René Moser
parent 0f12e1c7d8
commit e7c39460ed

@ -0,0 +1,2 @@
bugfixes:
- 'ipaddr: prevent integer indices from being parsed as ip nets'

@ -630,7 +630,7 @@ def ipaddr(value, query='', version=False, alias='ipaddr'):
# address/network is inside that specific subnet
try:
# ?? 6to4 and link-local were True here before. Should they still?
if query and (query not in query_func_map or query == 'cidr_lookup') and ipaddr(query, 'network'):
if query and (query not in query_func_map or query == 'cidr_lookup') and not str(query).isdigit() and ipaddr(query, 'network'):
iplist = netaddr.IPSet([netaddr.IPNetwork(query)])
query = 'cidr_lookup'
except Exception:

Loading…
Cancel
Save