homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: ipaddress module accepts octal formatted IPv4 addresses in IPv6 addresses
Type: behavior Stage: resolved
Components: Versions: Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Julian, iritkatriel, ncoghlan, pitrou, pmoody, xZise
Priority: normal Keywords: patch

Created on 2014年08月27日 09:33 by xZise, last changed 2022年04月11日 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
ipaddr.patch xZise, 2014年08月27日 13:06 review
Messages (3)
msg225950 - (view) Author: Fabian (xZise) * Date: 2014年08月27日 09:33
The ipaddress module accepts IPv6 addresses if the IPv4 address is formatted as an octal number, but http://tools.ietf.org/html/rfc3986#section-3.2.2 doesn't allow leading zeroes in the IPv4 address.
This is the current behaviour (in 3.4.1):
>>> ipaddress.ip_address("::1.0.0.00")
IPv6Address('::100:0')
Expected:
>>> ipaddress.ip_address("::1.0.0.00")
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
 File "3.4.1/lib/python3.4/ipaddress.py", line 54, in ip_address
 address)
ValueError: '::1.0.0.00' does not appear to be an IPv4 or IPv6 address
Because I didn't know it better, I first tried to patch the backport but this might be still applicable the official code: https://github.com/phihag/ipaddress/pull/12 
msg225983 - (view) Author: Fabian (xZise) * Date: 2014年08月27日 13:06
The patch adds an optional keyword which only accepts decimal numbers.
msg408058 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2021年12月09日 00:24
This is what I get now on 3.11:
>>> ipaddress.ip_address("::1.0.0.00")
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
 File "C:\Users\User\src\cpython\Lib\ipaddress.py", line 54, in ip_address
 raise ValueError('%r does not appear to be an IPv4 or IPv6 address' %
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: '::1.0.0.00' does not appear to be an IPv4 or IPv6 address
History
Date User Action Args
2022年04月11日 14:58:07adminsetgithub: 66478
2021年12月09日 00:24:12iritkatrielsetstatus: open -> closed

nosy: + iritkatriel
messages: + msg408058

resolution: fixed
stage: resolved
2021年04月11日 23:00:33Juliansetnosy: + Julian
2014年08月29日 01:33:52berker.peksagsetnosy: + ncoghlan, pitrou, pmoody
2014年08月27日 13:06:02xZisesetfiles: + ipaddr.patch
keywords: + patch
messages: + msg225983
2014年08月27日 09:33:26xZisecreate

AltStyle によって変換されたページ (->オリジナル) /