Merged changes from @lukasa
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Roberto Migli · committed by Roberto Migli · parents a6a8342, 5b4e9af · Browse files · 3 files·+12 added−16 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+12 added−16 removed
- other:+12 added−16 removed
Provenance
- Commit
49fb630- Tree
67102ae- Author
Roberto Migli <robertomigli@gmail.com>- Committer
Roberto Migli <robertomigli@gmail.com>- Parent 1
a6a8342- Parent 2
5b4e9af
3 files changed+12 added−16 removed
modified:requests/adapters.py-4 removed
284 unmodified lines285 headers = {}286 username, password = get_auth_from_url(proxy)287 288 if username and password:289- # Proxy auth usernames and passwords will be urlencoded, we need290- # to decode them.291- username = unquote(username)292- password = unquote(password)289 headers['Proxy-Authorization'] = _basic_auth_str(username,290 password)291 292 return headers104 unmodified linesmodified:requests/utils.py+7 added-11 removed
632 unmodified lines633 634 def get_auth_from_url(url):635 """Given a url with authentication components, extract them into a tuple of636 username,password."""637- if url:638- parsed = urlparse(url)637+ parsed = urlparse(url)639- username = ""640- password = ""638 642- if parsed.username is not None:643- username = unquote(parsed.username)644- if parsed.password is not None:645- password = unquote(parsed.password)646- return (username, password)647- else:648- return ('', '')639+ try:640+ auth = (unquote(parsed.username), unquote(parsed.password))641+ except (AttributeError, TypeError):642+ auth = ('', '')643 644+ return auth645 646+647 def to_native_string(string, encoding='ascii'):648 """649 Given a string object, regardless of type, returns a representation of that650 string in the native string type, encoding and decoding where necessary.13 unmodified linesmodified:test_requests.py+5 added-1 removed
192 unmodified lines193 # Make sure the cookie was sent194 assert r.json()['cookies']['foo'] == 'bar'195 # Make sure the session cj is still the custom one196 assert s.cookies is cj197- 197+198 def test_param_cookiejar_works(self):199 cj = cookielib.CookieJar()200 cookiejar_from_dict({'foo' : 'bar'}, cj)201 s = requests.session()502 unmodified lines704 def test_get_auth_from_url_percent_chars(self):705 url = 'http://user%25user:pass@complex.url.com/path?query=yes'706 assert ('user%user', 'pass') == requests.utils.get_auth_from_url(url)707 708+ def test_get_auth_from_url_encoded_hashes(self):709+ url = 'http://user:pass%23pass@complex.url.com/path?query=yes'710+ assert ('user', 'pass#pass') == requests.utils.get_auth_from_url(url)711+712 def test_cannot_send_unprepared_requests(self):713 r = requests.Request(url=HTTPBIN)714 with pytest.raises(ValueError):715 requests.Session().send(r)454 unmodified lines