Skip to content
Myr

Unquote the auth after splitting the url.

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

authored by Cory Benfield · committed by Cory Benfield · parent ac4e058 · Browse files · 2 files+12 added−5 removed
This commit

State

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

Diff stats

2 files+12 added−5 removed

  • other:+12 added−5 removed

2 files+12 added−5 removed

modified:requests/utils.py+7 added-4 removed
633 unmodified lines
634def get_auth_from_url(url):635 """Given a url with authentication components, extract them into a tuple of636 username,password."""637 if url:638 url = unquote(url)638 parsed = urlparse(url)640 return (parsed.username, parsed.password)641 else:642 return ('', '')639640 try:641 return (unquote(parsed.username), unquote(parsed.password))642 except AttributeError:643 pass644645 return ('', '')646647648def to_native_string(string, encoding='ascii'):649 """650 Given a string object, regardless of type, returns a representation of that651 string in the native string type, encoding and decoding where necessary.
13 unmodified lines
modified:test_requests.py+5 added-1 removed
192 unmodified lines
193 # 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 197198 def test_param_cookiejar_works(self):199 cj = cookielib.CookieJar()200 cookiejar_from_dict({'foo' : 'bar'}, cj)201 s = requests.session()
502 unmodified lines
704 def test_get_auth_from_url_percent_chars(self):705 url = 'http://user%user:pass@complex.url.com/path?query=yes'706 assert ('user%user', 'pass') == requests.utils.get_auth_from_url(url)707708 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)711712 def test_cannot_send_unprepared_requests(self):713 r = requests.Request(url=HTTPBIN)714 with pytest.raises(ValueError):715 requests.Session().send(r)
445 unmodified lines