-
Notifications
You must be signed in to change notification settings - Fork 38
Open
Description
In some cases, redirects may lead to malformed (partial) URLs. This may create to a request without the domain name, which is not handled by the requests package.
The problem seems to be on line 170 when the server presents a redirect without the domain name. This is properly handled on line 163 where it prepends singlekey_host when necessary, but this step is not performed at line 170. When singlekey_host is also (conditionally) prepended after line 170, this crash is resolved for me.
Tested on macOS 14.1.2 using Python 3.11. A partial debug output is given below.
--------
return_url='https://singlekey-id.com/auth/connect/authorize/callback?client_id=[...]', <Response [302]>
return_url='https://singlekey-id.com/auth/login?returnUrl=%2Fauth%2Fconnect%2Fauthorize%2Fcallback%3Fclient_id%[...]', <Response [302]>
Traceback (most recent call last):
File "/Users/jorrit/Documents/Projects/home_control_py/./hc-login", line 167, in <module>
r = session.get(return_url, allow_redirects=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jorrit/Documents/Projects/home_control_py/venv/lib/python3.11/site-packages/requests/sessions.py", line 602, in get
return self.request("GET", url, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jorrit/Documents/Projects/home_control_py/venv/lib/python3.11/site-packages/requests/sessions.py", line 575, in request
prep = self.prepare_request(req)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jorrit/Documents/Projects/home_control_py/venv/lib/python3.11/site-packages/requests/sessions.py", line 486, in prepare_request
p.prepare(
File "/Users/jorrit/Documents/Projects/home_control_py/venv/lib/python3.11/site-packages/requests/models.py", line 368, in prepare
self.prepare_url(url, params)
File "/Users/jorrit/Documents/Projects/home_control_py/venv/lib/python3.11/site-packages/requests/models.py", line 439, in prepare_url
raise MissingSchema(
requests.exceptions.MissingSchema: Invalid URL '/auth/en-gb/login?returnUrl=%2Fauth%2Fconnect%2Fauthorize%2Fcallback%3Fclient_id%[...]': No scheme supplied. Perhaps you meant https:///auth/en-gb/login?returnUrl=%2Fauth%2Fconnect%2Fauthorize%2Fcallback%3Fclient_id%[...]?
pmagyar
Metadata
Metadata
Assignees
Labels
No labels