File tree 2 files changed +12
-2
lines changed
2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -1125,6 +1125,11 @@ def test_invalid_bracketed_hosts(self):
1125
1125
urllib .parse .urlsplit (case ).hostname
1126
1126
with self .assertRaises (ValueError ):
1127
1127
urllib .parse .urlparse (case ).hostname
1128
+ bytes_case = case .encode ('utf8' )
1129
+ with self .assertRaises (ValueError ):
1130
+ urllib .parse .urlsplit (bytes_case ).hostname
1131
+ with self .assertRaises (ValueError ):
1132
+ urllib .parse .urlparse (bytes_case ).hostname
1128
1133
1129
1134
def test_splitting_bracketed_hosts (self ):
1130
1135
p1 = urllib .parse .urlsplit ('scheme://user@[v6a.ip]/path?query' )
Original file line number Diff line number Diff line change @@ -241,10 +241,15 @@ def _userinfo(self):
241
241
def _hostinfo (self ):
242
242
netloc = self .netloc
243
243
_ , _ , hostinfo = netloc .rpartition (b'@' )
244
- _ , have_open_br , bracketed = hostinfo .partition (b'[' )
244
+ bracket_prefix , have_open_br , bracketed = hostinfo .partition (b'[' )
245
245
if have_open_br :
246
+ if bracket_prefix :
247
+ raise ValueError ('Invalid IPv6 URL' )
246
248
hostname , _ , port = bracketed .partition (b']' )
247
- _ , _ , port = port .partition (b':' )
249
+ _check_bracketed_host (hostname .decode (_implicit_encoding , _implicit_errors ))
250
+ bracket_suffix , _ , port = port .partition (b':' )
251
+ if bracket_suffix :
252
+ raise ValueError ('Invalid IPv6 URL' )
248
253
else :
249
254
hostname , _ , port = hostinfo .partition (b':' )
250
255
if not port :
You can’t perform that action at this time.
0 commit comments