Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

safe_url_string should not escape unreserved marks (see RFC 2396, sec 2.3)

olveyraa38c72bb0526
diff --git a/scrapy/trunk/scrapy/utils/url.py b/scrapy/trunk/scrapy/utils/url.py
index 408e37b4e..091827760 100644
--- a/scrapy/trunk/scrapy/utils/url.py
+++ b/scrapy/trunk/scrapy/utils/url.py
@@ -37,7 +37,8 @@ def urljoin_rfc(base, ref):
_reserved = ';/?:@&=+$|,#' # RFC 2396 (Generic Syntax)
-_safe_chars = urllib.always_safe + '%' + _reserved
+_unreserved_marks = "-_.!~*'()" #RFC 2396 sec 2.3
+_safe_chars = urllib.always_safe + '%' + _reserved + _unreserved_marks
def safe_url_string(url, use_encoding='utf8'):
"""Convert a unicode (or utf8 string) object into a legal URL.