Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
241a0437
Kaydet (Commit)
241a0437
authored
Nis 20, 2010
tarafından
Senthil Kumaran
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue2987 - Added additional Invalid URL and changed the Invalid URL checking code for better.
üst
c166b402
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
6 deletions
+9
-6
test_urlparse.py
Lib/test/test_urlparse.py
+1
-0
urlparse.py
Lib/urlparse.py
+8
-6
No files found.
Lib/test/test_urlparse.py
Dosyayı görüntüle @
241a0437
...
@@ -272,6 +272,7 @@ class UrlParseTestCase(unittest.TestCase):
...
@@ -272,6 +272,7 @@ class UrlParseTestCase(unittest.TestCase):
for
invalid_url
in
[
for
invalid_url
in
[
'http://::12.34.56.78]/'
,
'http://::12.34.56.78]/'
,
'http://[::1/foo/'
,
'http://[::1/foo/'
,
'http://[::1/foo/bad]/bad'
,
'http://[::ffff:12.34.56.78'
]:
'http://[::ffff:12.34.56.78'
]:
self
.
assertRaises
(
ValueError
,
lambda
:
urlparse
.
urlparse
(
invalid_url
)
.
hostname
)
self
.
assertRaises
(
ValueError
,
lambda
:
urlparse
.
urlparse
(
invalid_url
)
.
hostname
)
self
.
assertRaises
(
ValueError
,
lambda
:
urlparse
.
urlparse
(
invalid_url
))
self
.
assertRaises
(
ValueError
,
lambda
:
urlparse
.
urlparse
(
invalid_url
))
...
...
Lib/urlparse.py
Dosyayı görüntüle @
241a0437
...
@@ -90,8 +90,6 @@ class ResultMixin(object):
...
@@ -90,8 +90,6 @@ class ResultMixin(object):
netloc
=
self
.
netloc
.
split
(
'@'
)[
-
1
]
netloc
=
self
.
netloc
.
split
(
'@'
)[
-
1
]
if
'['
in
netloc
and
']'
in
netloc
:
if
'['
in
netloc
and
']'
in
netloc
:
return
netloc
.
split
(
']'
)[
0
][
1
:]
.
lower
()
return
netloc
.
split
(
']'
)[
0
][
1
:]
.
lower
()
elif
'['
in
netloc
or
']'
in
netloc
:
raise
ValueError
(
"Invalid IPv6 hostname"
)
elif
':'
in
netloc
:
elif
':'
in
netloc
:
return
netloc
.
split
(
':'
)[
0
]
.
lower
()
return
netloc
.
split
(
':'
)[
0
]
.
lower
()
elif
netloc
==
''
:
elif
netloc
==
''
:
...
@@ -151,10 +149,6 @@ def _splitparams(url):
...
@@ -151,10 +149,6 @@ def _splitparams(url):
def
_splitnetloc
(
url
,
start
=
0
):
def
_splitnetloc
(
url
,
start
=
0
):
delim
=
len
(
url
)
# position of end of domain part of url, default is end
delim
=
len
(
url
)
# position of end of domain part of url, default is end
if
'['
in
url
:
# check for invalid IPv6 URL
if
not
']'
in
url
:
raise
ValueError
(
"Invalid IPv6 URL"
)
elif
']'
in
url
:
if
not
'['
in
url
:
raise
ValueError
(
"Invalid IPv6 URL"
)
for
c
in
'/?#'
:
# look for delimiters; the order is NOT important
for
c
in
'/?#'
:
# look for delimiters; the order is NOT important
wdelim
=
url
.
find
(
c
,
start
)
# find first of this delim
wdelim
=
url
.
find
(
c
,
start
)
# find first of this delim
if
wdelim
>=
0
:
# if found
if
wdelim
>=
0
:
# if found
...
@@ -182,6 +176,10 @@ def urlsplit(url, scheme='', allow_fragments=True):
...
@@ -182,6 +176,10 @@ def urlsplit(url, scheme='', allow_fragments=True):
url
=
url
[
i
+
1
:]
url
=
url
[
i
+
1
:]
if
url
[:
2
]
==
'//'
:
if
url
[:
2
]
==
'//'
:
netloc
,
url
=
_splitnetloc
(
url
,
2
)
netloc
,
url
=
_splitnetloc
(
url
,
2
)
if
'['
in
netloc
:
if
not
']'
in
netloc
:
raise
ValueError
(
"Invalid IPv6 URL"
)
if
']'
in
netloc
:
if
not
'['
in
netloc
:
raise
ValueError
(
"Invalid IPv6 URL"
)
if
allow_fragments
and
'#'
in
url
:
if
allow_fragments
and
'#'
in
url
:
url
,
fragment
=
url
.
split
(
'#'
,
1
)
url
,
fragment
=
url
.
split
(
'#'
,
1
)
if
'?'
in
url
:
if
'?'
in
url
:
...
@@ -197,6 +195,10 @@ def urlsplit(url, scheme='', allow_fragments=True):
...
@@ -197,6 +195,10 @@ def urlsplit(url, scheme='', allow_fragments=True):
if
url
[:
2
]
==
'//'
:
if
url
[:
2
]
==
'//'
:
netloc
,
url
=
_splitnetloc
(
url
,
2
)
netloc
,
url
=
_splitnetloc
(
url
,
2
)
if
'['
in
netloc
:
if
not
']'
in
netloc
:
raise
ValueError
(
"Invalid IPv6 URL"
)
if
']'
in
netloc
:
if
not
'['
in
netloc
:
raise
ValueError
(
"Invalid IPv6 URL"
)
if
allow_fragments
and
scheme
in
uses_fragment
and
'#'
in
url
:
if
allow_fragments
and
scheme
in
uses_fragment
and
'#'
in
url
:
url
,
fragment
=
url
.
split
(
'#'
,
1
)
url
,
fragment
=
url
.
split
(
'#'
,
1
)
if
scheme
in
uses_query
and
'?'
in
url
:
if
scheme
in
uses_query
and
'?'
in
url
:
...
...
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