This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jerith
Recipients hfuru, jerith, orsenthil, vstinner
Date 2010-11-20.19:09:56
SpamBayes Score 2.3685452e-06
Marked as misclassified No
Message-id <1290280198.27.0.333542204475.issue10231@psf.upfronthosting.co.za>
In-reply-to
Content
Thanks for the comments.

There are two separate things here: the URL and the filesystem path. The only part of the URL we care about is the path section, but the fragment ("#anchor") and query parameters ("?foo") are valid -- SimpleHTTPRequestHandler just ignores them. translate_path() turns the URL into the filesystem path, which may be a file or a directory, by extracting the URL path and mapping it onto the filesystem.

The bug is that the fragment and query parameters are stripped in translate_path(), but are *not* stripped when manipulating the URL for the redirect.

This means that when the URL is "/something?foo" and the cwd is "/tmp", the filesystem path is "/tmp/something" (which is a directory) and therefore the response needs to be a redirect. The redirect needs to modify the path section of the URL (which is "/something") to add a slash. This means the redirect needs to be to "/something/" (or "/something/?foo" if you want to preserve the query parameters) rather than "/something?foo/" which is what the current implementation does.

translate_path() unescapes the URL path before mapping it to the filesystem, which means that "/something%3Ffoo" (and even "/something%3Ffoo?bar") will be turned into the filesystem path "/tmp/something?foo".

I'll add some tests for the "/something%3Ffoo" case and possibly update send_head() to preserve the fragment and query parameters on redirect.
History
Date User Action Args
2010-11-20 19:09:58jerithsetrecipients: + jerith, hfuru, orsenthil, vstinner
2010-11-20 19:09:58jerithsetmessageid: <1290280198.27.0.333542204475.issue10231@psf.upfronthosting.co.za>
2010-11-20 19:09:56jerithlinkissue10231 messages
2010-11-20 19:09:56jerithcreate