summaryrefslogtreecommitdiffstats
path: root/Lib/urllib/parse.py
diff options
context:
space:
mode:
authorpostmasters <namnguyen@google.com>2017-06-20 13:02:44 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2017-06-20 13:02:44 (GMT)
commit90e01e50ef8a9e6c91f30d965563c378a4ad26de (patch)
treee467f98aa737fb5c517df080f25d7734d81a5d55 /Lib/urllib/parse.py
parent5cc7ac24da10568d2a910a91a24183b904118cf8 (diff)
downloadcpython-90e01e50ef8a9e6c91f30d965563c378a4ad26de.zip
cpython-90e01e50ef8a9e6c91f30d965563c378a4ad26de.tar.gz
cpython-90e01e50ef8a9e6c91f30d965563c378a4ad26de.tar.bz2
urllib: Simplify splithost by calling into urlparse. (#1849)
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``.
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 1af2906..01eb549 100644
--- a/Lib/urllib/parse.py
+++ b/Lib/urllib/parse.py
@@ -947,7 +947,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: