Skip to content

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

Do not consider about: URLs invalid

Adrián Chavese40788153ca7
diff --git a/scrapy/http/request/__init__.py b/scrapy/http/request/__init__.py
index ef58deacc..498f1b052 100644
--- a/scrapy/http/request/__init__.py
+++ b/scrapy/http/request/__init__.py
@@ -65,7 +65,11 @@ class Request(object_ref):
s = safe_url_string(url, self.encoding)
self._url = escape_ajax(s)
- if ('://' not in self._url) and (not self._url.startswith('data:')):
+ if (
+ '://' not in self._url
+ and not self._url.startswith('about:')
+ and not self._url.startswith('data:')
+ ):
raise ValueError(f'Missing scheme in request url: {self._url}')
url = property(_get_url, obsolete_setter(_set_url, 'url'))
diff --git a/tests/test_http_request.py b/tests/test_http_request.py
index 0a303dbe2..74579dfc4 100644
--- a/tests/test_http_request.py
+++ b/tests/test_http_request.py
@@ -43,6 +43,15 @@ class RequestTest(unittest.TestCase):
assert r.headers is not headers
self.assertEqual(r.headers[b"caca"], b"coco")
+ def test_url_scheme(self):
+ # This test passes by not raising any (ValueError) exception
+ self.request_class('http://example.org')
+ self.request_class('https://example.org')
+ self.request_class('s3://example.org')
+ self.request_class('ftp://example.org')
+ self.request_class('about:config')
+ self.request_class('data:,Hello%2C%20World!')
+
def test_url_no_scheme(self):
self.assertRaises(ValueError, self.request_class, 'foo')
self.assertRaises(ValueError, self.request_class, '/foo/')