fix #2552 by improving request schema check on its initialization

This commit is contained in:
Victor Torres 2019-10-22 10:48:02 -03:00
parent 1d5c270ce8
commit f701f5b0db
2 changed files with 3 additions and 1 deletions

View File

@ -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'))

View File

@ -52,6 +52,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