Skip to content
Myr

Merge pull request #1710 from jvantuyl/master

Before adoption: this commit came in with the history the project adopted, so no landing records it.

loosen URL handling for non-native protocols

authored by Kenneth Reitz · committed by Kenneth Reitz · parents 2e196be, a9ec28a · Browse files · 3 files+15 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+15 added−0 removed

  • other:+15 added−0 removed

3 files+15 added−0 removed

modified:requests/packages/urllib3/util.py+2 added
363 unmodified lines
364365 # Scheme366 if '://' in url:367 scheme, url = url.split('://', 1)368 elif ':' in url:369 scheme, url = url.split(':', 1)370371 # Find the earliest Authority Terminator372 # (http://tools.ietf.org/html/rfc3986#section-3.2)373 url, path_, delim = split_first(url, ['/', '?', '#'])
264 unmodified lines
modified:requests/models.py+5 added
325 unmodified lines
326 if not scheme:327 raise MissingSchema("Invalid URL {0!r}: No schema supplied. "328 "Perhaps you meant http://{0}?".format(url))329330 # Don't do any URL preparation for oddball schemes331 if scheme.lower() not in ('http', 'https'):332 self.url = url333 return334335 if not host:336 raise InvalidURL("Invalid URL %r: No host supplied" % url)337338 # Only want to apply IDNA to the hostname
401 unmodified lines
modified:test_requests.py+8 added
676 unmodified lines
677 p = req.prepare()678679 assert p.headers['Content-Length'] == length680681 def test_oddball_schemes_dont_check_URLs(self):682 r1 = requests.Request('GET', 'data:image/gif;base64,R0lGODlhAQABAHAAACH5BAUAAAAALAAAAAABAAEAAAICRAEAOw==')683 r1.prepare()684 r2 = requests.Request('GET', 'file:///etc/passwd')685 r2.prepare()686 r3 = requests.Request('GET', 'magnet:?xt=urn:btih:be08f00302bc2d1d3cfa3af02024fa647a271431')687 r3.prepare()688689class TestContentEncodingDetection(unittest.TestCase):690691 def test_none(self):692 encodings = requests.utils.get_encodings_from_content('')
201 unmodified lines