[issue20271] urllib.parse.urlparse() accepts wrong URLs

STINNER Victor report at bugs.python.org
Fri Mar 7 17:19:24 CET 2014


STINNER Victor added the comment:

Here is a patch for Python 3.5 which breaks backward compatibility: urlparse functions now raise a ValueError if the IPv6 address, port or host is invalid.

Examples of invalid URLs:

- "HTTP://WWW.PYTHON.ORG:65536/doc/#frag": 65536 is invalid
- "http://www.example.net:foo"
- "http://::1/"
- "http://[127.0.0.1]/"
- "http://[host]/"

According to unit tests, Python 3.4 is more tolerant: it only raises an error when the port number is read (obj.port) from an URL with an invalid port. There error is not raised when the whole URL is parsed.

Is it ok to break backward compatibility?

----------
keywords: +patch
nosy: +gvanrossum, haypo
Added file: http://bugs.python.org/file34300/urlparse.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue20271>
_______________________________________


More information about the Python-bugs-list mailing list