summaryrefslogtreecommitdiffstats
path: root/Lib/urllib/parse.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2017-06-20 13:37:24 (GMT)
committerGitHub <noreply@github.com>2017-06-20 13:37:24 (GMT)
commit536c1f1246f4faa302f9f5613fc3444e7ae09b4a (patch)
tree699718dbe3fa36c47e03dab75a8bfd68e2b5a6ff /Lib/urllib/parse.py
parent0a4fe1d8578fa59004518f8deef137282be4d71a (diff)
downloadcpython-536c1f1246f4faa302f9f5613fc3444e7ae09b4a.zip
cpython-536c1f1246f4faa302f9f5613fc3444e7ae09b4a.tar.gz
cpython-536c1f1246f4faa302f9f5613fc3444e7ae09b4a.tar.bz2
bpo-30500: urllib: Simplify splithost by calling into urlparse. (#1849) (#2289)
The current regex based splitting produces a wrong result. For example:: http://abc#@def Web browsers parse that URL as ``http://abc/#@def``, that is, the host is ``abc``, the path is ``/``, and the fragment is ``#@def``. (cherry picked from commit 90e01e50ef8a9e6c91f30d965563c378a4ad26de)
Diffstat (limited to 'Lib/urllib/parse.py')
-rw-r--r--Lib/urllib/parse.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/Lib/urllib/parse.py b/Lib/urllib/parse.py
index 888247b..3cab2d1 100644
--- a/Lib/urllib/parse.py
+++ b/Lib/urllib/parse.py
@@ -944,7 +944,7 @@ def splithost(url):
"""splithost('//host[:port]/path') --> 'host[:port]', '/path'."""
global _hostprog
if _hostprog is None:
- _hostprog = re.compile('//([^/?]*)(.*)', re.DOTALL)
+ _hostprog = re.compile('//([^/#?]*)(.*)', re.DOTALL)
match = _hostprog.match(url)
if match: