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
98a4dcef
Commit
98a4dcef
authored
May 01, 2019
by
Steve Dower
Committed by
GitHub
May 01, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-36742: Fixes handling of pre-normalization characters in urlsplit() (GH-13017)
parent
3e5c4a7c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
4 deletions
+14
-4
Lib/test/test_urlparse.py
Lib/test/test_urlparse.py
+6
-0
Lib/urlparse.py
Lib/urlparse.py
+7
-4
Misc/NEWS.d/next/Security/2019-04-29-15-34-59.bpo-36742.QCUY0i.rst
....d/next/Security/2019-04-29-15-34-59.bpo-36742.QCUY0i.rst
+1
-0
No files found.
Lib/test/test_urlparse.py
View file @
98a4dcef
...
...
@@ -641,6 +641,12 @@ class UrlParseTestCase(unittest.TestCase):
self
.
assertIn
(
u'
\
u2100
'
,
denorm_chars
)
self
.
assertIn
(
u'
\
uFF03
'
,
denorm_chars
)
# bpo-36742: Verify port separators are ignored when they
# existed prior to decomposition
urlparse
.
urlsplit
(
u'http://
\
u30d5
\
u309a
:80'
)
with
self
.
assertRaises
(
ValueError
):
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
)
...
...
Lib/urlparse.py
View file @
98a4dcef
...
...
@@ -171,13 +171,16 @@ def _checknetloc(netloc):
# looking for characters like \u2100 that expand to 'a/c'
# IDNA uses NFKC equivalence, so normalize for this check
import
unicodedata
netloc2
=
unicodedata
.
normalize
(
'NFKC'
,
netloc
)
if
netloc
==
netloc2
:
n
=
netloc
.
rpartition
(
'@'
)[
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
(
'?'
,
''
)
netloc2
=
unicodedata
.
normalize
(
'NFKC'
,
n
)
if
n
==
netloc2
:
return
_
,
_
,
netloc
=
netloc
.
rpartition
(
'@'
)
# anything to the left of '@' is okay
for
c
in
'/?#@:'
:
if
c
in
netloc2
:
raise
ValueError
(
"netloc '"
+
netloc
2
+
"' contains invalid "
+
raise
ValueError
(
"netloc '"
+
netloc
+
"' contains invalid "
+
"characters under NFKC normalization"
)
def
urlsplit
(
url
,
scheme
=
''
,
allow_fragments
=
True
):
...
...
Misc/NEWS.d/next/Security/2019-04-29-15-34-59.bpo-36742.QCUY0i.rst
0 → 100644
View file @
98a4dcef
Fixes mishandling of pre-normalization characters in urlsplit().
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