urllib interpretation of URL with ".."

sergio sergio at sergiomb.no-ip.org
Tue Jun 26 16:26:06 EDT 2007


John Nagle wrote:

>  In Python, of course, "urlparse.urlparse", which is
> the main function used to disassemble a URL, has no idea whether it's
> being used by a client or a server, so it, reasonably enough, takes option
> 1.

>>> import urlparse
>>> base="http://somesite.com/level1/"
>>> path="../page.html"
>>> urlparse.urljoin(base,path)
'http://somesite.com/page.html'
>>> base="http://somesite.com/"
>>> urlparse.urljoin(base,path)
'http://somesite.com/../page.html'

For me this is a bug and is very annoying because I can't simply trip ../
from path because base could have a level.


-- 
Best regards,
--
Sérgio M. B. 



More information about the Python-list mailing list