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 v+python
Recipients orsenthil, v+python
Date 2012-04-13.08:58:24
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1334307505.0.0.455149916981.issue14567@psf.upfronthosting.co.za>
In-reply-to
Content
I finally understand the purpose of the checks in translate path...
Basically, translate path is concatenating the URL path to the current directory (because that is considered the root for Web service by this
server).  But along the way, it does normalization (redundantly compared to _url_collapse_path, but for a different code path, and sadly, using a different algorithm that gets different results), and os-specific checks.

For the os-specific checks, it does a couple splits to see if each path component contains a drive letter or "character other than / that is used as a directory separator", or contains "." or ".." (os specific versions).

It doesn't check for os-specific illegal filename characters (but of course they will not match existing files on the OS, so that eventually would cause a 404).

Such checks are probably best done only on path components that are actually traversed, the only problem is that increasingly large subsets of the path are passed to translate_path by run_cgi so the net effect is an O(n-squared) performance characteristic: most actual paths do not get too long, happily, but it is still inefficient.

Factoring out the checks into a function that could be called by translate path or run_cgi might be appropriate, and then run_cgi could call the new function piece by piece instead of calling translate_path at all.  It would also be good to make translate path produce an error if "drive" or "head" are ever non-empty.
History
Date User Action Args
2012-04-13 08:58:25v+pythonsetrecipients: + v+python, orsenthil
2012-04-13 08:58:25v+pythonsetmessageid: <1334307505.0.0.455149916981.issue14567@psf.upfronthosting.co.za>
2012-04-13 08:58:24v+pythonlinkissue14567 messages
2012-04-13 08:58:24v+pythoncreate