HTTP redirection does not handle correctly locations with url-encoded content
Oldes opened this issue · 1 comments
Oldes commented
Example is reading release files from GitHub:
>> read https://github.com/upx/upx/releases/download/v3.96/upx-3.96-win32.zip
...
Location: {https://github-releases.githubusercontent.com/67031040/2f297180-3d73-11ea-81eb-e3192446510e?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20210304%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210304T095933Z&X-Amz-Expires=300&X-Amz-Signature=daef518d6ed958abf0892144b2232041583129ef451be0f6e55f5ff5deafb3fb&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=67031040&response-content-disposition=attachment%3B%20filename%3Dupx-3.96-win32.zip&response-content-type=application%2Foctet-stream}
...
[HTTP] Redirect to: https://github-releases.githubusercontent.com/67031040/2f297180-3d73-11ea-81eb-e3192446510e?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%252F20210304%252Fus-east-1%252Fs3%252Faws4_request&X-Amz-Date=20210304T095933Z&X-Amz-Expires=300&X-Amz-Signature=daef518d6ed958abf0892144b2232041583129ef451be0f6e55f5ff5deafb3fb&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=67031040&response-content-disposition=attachment%253B%2520filename%253Dupx-3.96-win32.zip&response-content-type=application%252Foctet-stream
...
** Access error: protocol error: "Server error: HTTP/1.1 400 Bad Request"
Notice that for example: application%2Foctet-stream
from the location is converted to: application%252Foctet-stream
, which is cause of the problem!
Oldes commented
The commit above fixed the issue, but I'm not sure, if there it would not cause problems elsewhere... there should be more extensive HTTP tests... but not at this moment.