Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
f61599b0
Commit
f61599b0
authored
Jun 04, 2019
by
Steve Dower
Committed by
GitHub
Jun 04, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-36742: Corrects fix to handle decomposition in usernames (GH-13812)
parent
74bede0d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
12 deletions
+13
-12
Lib/test/test_urlparse.py
Lib/test/test_urlparse.py
+7
-6
Lib/urlparse.py
Lib/urlparse.py
+6
-6
No files found.
Lib/test/test_urlparse.py
View file @
f61599b0
...
...
@@ -648,12 +648,13 @@ class UrlParseTestCase(unittest.TestCase):
urlparse
.
urlsplit
(
u'http://
\
u30d5
\
u309a
\
ufe13
80'
)
for
scheme
in
[
u"http"
,
u"https"
,
u"ftp"
]:
for
c
in
denorm_chars
:
url
=
u"{}://netloc{}false.netloc/path"
.
format
(
scheme
,
c
)
if
test_support
.
verbose
:
print
"Checking %r"
%
url
with
self
.
assertRaises
(
ValueError
):
urlparse
.
urlsplit
(
url
)
for
netloc
in
[
u"netloc{}false.netloc"
,
u"n{}user@netloc"
]:
for
c
in
denorm_chars
:
url
=
u"{}://{}/path"
.
format
(
scheme
,
netloc
.
format
(
c
))
if
test_support
.
verbose
:
print
"Checking %r"
%
url
with
self
.
assertRaises
(
ValueError
):
urlparse
.
urlsplit
(
url
)
def
test_main
():
test_support
.
run_unittest
(
UrlParseTestCase
)
...
...
Lib/urlparse.py
View file @
f61599b0
...
...
@@ -171,17 +171,17 @@ def _checknetloc(netloc):
# looking for characters like \u2100 that expand to 'a/c'
# IDNA uses NFKC equivalence, so normalize for this check
import
unicodedata
n
=
netloc
.
r
partition
(
'@'
)[
2
]
# ignore anything to the left of '@'
n
=
n
.
replace
(
':'
,
''
)
# ignore characters already included
n
=
n
.
replace
(
'#'
,
''
)
# but not the surrounding text
n
=
n
.
replace
(
'?'
,
''
)
n
=
netloc
.
r
eplace
(
u'@'
,
u''
)
# ignore characters already included
n
=
n
.
replace
(
u':'
,
u''
)
# but not the surrounding text
n
=
n
.
replace
(
u'#'
,
u''
)
n
=
n
.
replace
(
u'?'
,
u
''
)
netloc2
=
unicodedata
.
normalize
(
'NFKC'
,
n
)
if
n
==
netloc2
:
return
for
c
in
'/?#@:'
:
if
c
in
netloc2
:
raise
ValueError
(
"netloc '"
+
netloc
+
"' contains invalid "
+
"characters under NFKC normalization"
)
raise
ValueError
(
u"netloc '"
+
netloc
+
u
"' contains invalid "
+
u
"characters under NFKC normalization"
)
def
urlsplit
(
url
,
scheme
=
''
,
allow_fragments
=
True
):
"""Parse a URL into 5 components:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment