mirror of
https://github.com/scrapy/scrapy.git
synced 2025-02-22 07:32:41 +00:00
Merge pull request #4094 from victor-torres/invalid-url
Improve URL schema validation on scrapy.Request initialization
This commit is contained in:
commit
25cd7ac7ab
@ -66,7 +66,7 @@ class Request(object_ref):
|
||||
s = safe_url_string(url, self.encoding)
|
||||
self._url = escape_ajax(s)
|
||||
|
||||
if ':' not in self._url:
|
||||
if ('://' not in self._url) and (not self._url.startswith('data:')):
|
||||
raise ValueError('Missing scheme in request url: %s' % self._url)
|
||||
|
||||
url = property(_get_url, obsolete_setter(_set_url, 'url'))
|
||||
|
@ -49,6 +49,8 @@ class RequestTest(unittest.TestCase):
|
||||
|
||||
def test_url_no_scheme(self):
|
||||
self.assertRaises(ValueError, self.request_class, 'foo')
|
||||
self.assertRaises(ValueError, self.request_class, '/foo/')
|
||||
self.assertRaises(ValueError, self.request_class, '/foo:bar')
|
||||
|
||||
def test_headers(self):
|
||||
# Different ways of setting headers attribute
|
||||
|
Loading…
x
Reference in New Issue
Block a user