Message121725
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. |
|
Date |
User |
Action |
Args |
2010-11-20 19:09:58 | jerith | set | recipients:
+ jerith, hfuru, orsenthil, vstinner |
2010-11-20 19:09:58 | jerith | set | messageid: <1290280198.27.0.333542204475.issue10231@psf.upfronthosting.co.za> |
2010-11-20 19:09:56 | jerith | link | issue10231 messages |
2010-11-20 19:09:56 | jerith | create | |
|