mirror of
https://github.com/kennethreitz/requests.git
synced 2026-06-05 22:50:18 +00:00
don't prepare URLs for oddball schemes
This commit is contained in:
@@ -327,6 +327,11 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin):
|
||||
raise MissingSchema("Invalid URL {0!r}: No schema supplied. "
|
||||
"Perhaps you meant http://{0}?".format(url))
|
||||
|
||||
# Don't do any URL preparation for oddball schemes
|
||||
if scheme.lower() not in ('http', 'https'):
|
||||
self.url = url
|
||||
return
|
||||
|
||||
if not host:
|
||||
raise InvalidURL("Invalid URL %r: No host supplied" % url)
|
||||
|
||||
|
||||
@@ -365,6 +365,8 @@ def parse_url(url):
|
||||
# Scheme
|
||||
if '://' in url:
|
||||
scheme, url = url.split('://', 1)
|
||||
elif ':' in url:
|
||||
scheme, url = url.split(':', 1)
|
||||
|
||||
# Find the earliest Authority Terminator
|
||||
# (http://tools.ietf.org/html/rfc3986#section-3.2)
|
||||
|
||||
@@ -678,6 +678,14 @@ class RequestsTestCase(unittest.TestCase):
|
||||
|
||||
assert p.headers['Content-Length'] == length
|
||||
|
||||
def test_oddball_schemes_dont_check_URLs(self):
|
||||
r1 = requests.Request('GET', 'data:image/gif;base64,R0lGODlhAQABAHAAACH5BAUAAAAALAAAAAABAAEAAAICRAEAOw==')
|
||||
r1.prepare()
|
||||
r2 = requests.Request('GET', 'file:///etc/passwd')
|
||||
r2.prepare()
|
||||
r3 = requests.Request('GET', 'magnet:?xt=urn:btih:be08f00302bc2d1d3cfa3af02024fa647a271431')
|
||||
r3.prepare()
|
||||
|
||||
class TestContentEncodingDetection(unittest.TestCase):
|
||||
|
||||
def test_none(self):
|
||||
|
||||
Reference in New Issue
Block a user