File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1425,6 +1425,11 @@ def test_invalid_bracketed_hosts(self):
14251425 urllib .parse .urlsplit (case ).hostname
14261426 with self .assertRaises (ValueError ):
14271427 urllib .parse .urlparse (case ).hostname
1428+ bytes_case = case .encode ('utf8' )
1429+ with self .assertRaises (ValueError ):
1430+ urllib .parse .urlsplit (bytes_case ).hostname
1431+ with self .assertRaises (ValueError ):
1432+ urllib .parse .urlparse (bytes_case ).hostname
14281433
14291434 def test_splitting_bracketed_hosts (self ):
14301435 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):
241241 def _hostinfo (self ):
242242 netloc = self .netloc
243243 _ , _ , hostinfo = netloc .rpartition (b'@' )
244- _ , have_open_br , bracketed = hostinfo .partition (b'[' )
244+ bracket_prefix , have_open_br , bracketed = hostinfo .partition (b'[' )
245245 if have_open_br :
246+ if bracket_prefix :
247+ raise ValueError ('Invalid IPv6 URL' )
246248 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' )
248253 else :
249254 hostname , _ , port = hostinfo .partition (b':' )
250255 if not port :
You can’t perform that action at this time.
0 commit comments