File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change 1+ import sys
12import os
23import unittest
34from inspect import isclass
102103 if (
103104 chr (value ) not in _C0_CONTROL_OR_SPACE
104105 and chr (value ) not in USERINFO_SAFE
105- and chr (value ) not in ":/?#\\ "
106+ and chr (value ) not in ":/?#\\ [] "
106107 )
107108)
108109USERNAME_ENCODED = "" .join (f"%{ ord (char ):02X} " for char in USERNAME_TO_ENCODE )
@@ -386,7 +387,6 @@ def test_safe_url_string_encoding(
386387 "http://192.168.0.256" , # Invalid IP address
387388 "http://192.168.0.0.0" , # Invalid IP address / domain name
388389 "http://[2a01:5cc0:1:2::4]" , # https://github.com/scrapy/w3lib/issues/193
389- "http://[2a01:5cc0:1:2:3:4]" , # Invalid IPv6
390390 "https://example.com:" , # Removes the :
391391 # Does not convert \ to /
392392 "https://example.com\\ a" ,
@@ -418,6 +418,8 @@ def test_safe_url_string_encoding(
418418 # (%) are not escaped.
419419 f"a://example.com#{ FRAGMENT_TO_ENCODE } " ,
420420}
421+ if sys .version_info < (3 , 11 , 4 ):
422+ KNOWN_SAFE_URL_STRING_URL_ISSUES .add ("http://[2a01:5cc0:1:2:3:4]" ) # Invalid IPv6
421423
422424
423425@pytest .mark .parametrize (
You can’t perform that action at this time.
0 commit comments