Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StaticRoute should unquote filename #1140

Closed
crccheck opened this issue Sep 1, 2016 · 2 comments · Fixed by #1161
Closed

StaticRoute should unquote filename #1140

crccheck opened this issue Sep 1, 2016 · 2 comments · Fixed by #1161
Labels

Comments

@crccheck
Copy link

crccheck commented Sep 1, 2016

Long story short

If I don't have web safe filenames (say I have a directory index), my browser turns "Darby uses the computer.jpg" into "Darby%20uses%20the%20computer.jpg", which StaticRoute will never find on the filesystem.

Expected behaviour

I expect to see

Actual behaviour

I get a 404 instead of a corgi.

Steps to reproduce

Take an existing static route with a working image. Add a space to the image, then add the same space to your url. That's not that helpful, but in the code, this change gets images to load again for me. I can attempt to turn it into a pull request, but not this week.

$ git rev-parse HEAD
671617dc4a343c18a26831c8941fd55b844ed977
diff --git a/aiohttp/web_urldispatcher.py b/aiohttp/web_urldispatcher.py
index 7b288fe..236701a 100644
--- a/aiohttp/web_urldispatcher.py
+++ b/aiohttp/web_urldispatcher.py
@@ -479,7 +479,7 @@ class StaticRoute(Route):

     @asyncio.coroutine
     def handle(self, request):
-        filename = request.match_info['filename']
+        filename = unquote(request.match_info['filename'])
         try:
             filepath = self._directory.joinpath(filename).resolve()
             filepath.relative_to(self._directory)

Your environment

Python 3.5.0+
aiohttp==0.22.5

@asvetlov asvetlov added the web label Sep 1, 2016
@asvetlov
Copy link
Member

asvetlov commented Sep 6, 2016

Agree with the problem but let's postpone the issue to 'after 1.0' times.

vir-mir added a commit to vir-mir/aiohttp that referenced this issue Sep 13, 2016
vir-mir added a commit to vir-mir/aiohttp that referenced this issue Sep 13, 2016
vir-mir added a commit to vir-mir/aiohttp that referenced this issue Sep 13, 2016
@vir-mir vir-mir mentioned this issue Sep 13, 2016
4 tasks
vir-mir added a commit to vir-mir/aiohttp that referenced this issue Sep 14, 2016
asvetlov pushed a commit that referenced this issue Sep 14, 2016
* fix #1140

fix #1140

* fix #1140
asvetlov pushed a commit that referenced this issue Sep 14, 2016
* fix #1140

fix #1140

* fix #1140
@lock
Copy link

lock bot commented Oct 29, 2019

This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue for
related bugs.

If you feel like there's important points made in this discussion,
please include those exceprts into that new issue.

@lock lock bot added the outdated label Oct 29, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants