Skip to content

Commit b92a222

Browse files
committed
Don't change | handling for now
1 parent 051ced0 commit b92a222

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

tests/test_url.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ def test_safe_url_string(self):
5959

6060
self.assertTrue(isinstance(safe_url_string(b'http://example.com/'), str))
6161

62+
def test_safe_url_string_unsafe_chars(self):
63+
safeurl = safe_url_string(r"http://localhost:8001/unwise{,},|,\,^,[,],`?|=[]&[]=|")
64+
self.assertEqual(safeurl, r"http://localhost:8001/unwise%7B,%7D,|,%5C,%5E,[,],%60?|=[]&[]=|")
65+
6266
def test_safe_url_string_with_query(self):
6367
safeurl = safe_url_string(u"http://www.example.com/£?unit=µ")
6468
self.assertTrue(isinstance(safeurl, str))

w3lib/url.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ def _quote_byte(error):
3030
RFC3986_SUB_DELIMS = b"!$&'()*+,;="
3131
RFC3986_RESERVED = RFC3986_GEN_DELIMS + RFC3986_SUB_DELIMS
3232
RFC3986_UNRESERVED = (string.ascii_letters + string.digits + "-._~").encode('ascii')
33+
EXTRA_SAFE_CHARS = b'|' # see https://github.com/scrapy/w3lib/pull/25
3334

34-
35-
_safe_chars = RFC3986_RESERVED + RFC3986_UNRESERVED + b'%'
35+
_safe_chars = RFC3986_RESERVED + RFC3986_UNRESERVED + EXTRA_SAFE_CHARS + b'%'
3636

3737
def safe_url_string(url, encoding='utf8', path_encoding='utf8'):
3838
"""Convert the given URL into a legal URL by escaping unsafe characters

0 commit comments

Comments
 (0)