You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just try it this way.
>>> print urlparse.urljoin('http://site.com/', 'path/../path/.././path/./')
http://site.com/path/
>>>
The difference is the inital '/' in the second argument.
Human interpretation is:
Go to http://site.com/ and 1) go to path directory 2) go to one-level
above (/../) which results in site.com again 3) go to path directory 4)
go to one-level above (..) (results site.com )5) Stay in the same
directory (.) 6) goto path 7) stay there (.)
Final result is http://www.site.com/path/
When you start the path with a '/'
>>> print urlparse.urljoin('http://site.com/', '/path/../path/.././path/./')
http://site.com/path/../path/.././path/./
The RFC (1808) suggests the following.
urlparse.urljoin('http://a/b/c/d','/./g') = <URL:http://a/./g\>
The argument is taken as a complete path for the server.
Btw, Thank you for the exciting report monk.e.boy. :-)
There are many hidden in urlparse,urllib*. I hope you will have fun time
finding them (and fixing them too :)
And one general comment. If the bug is valid, Python official
Documentation cannot be made to reference a blog site. Instead, a patch
to fix the python doc would itself be welcome.
Activity
monkeboy commentedon Apr 8, 2008
Hi,
This is my first problem with anything Python :-) and my first issue.
Doing in the following:
These URLs are normalized to http://site.com/path/ in both Firefox and
Google (the google spider would follow these OK)
I think the documentation could be improved to point at the
posixpath.py normpath function and how it solves the above. I blogged a
how to:
http://teethgrinder.co.uk/blog/Normalize-URL-path-python/
I hope my bug report is OK. Thanks for all the code :-)
johng@neutralize.com
orsenthil commentedon May 16, 2008
The difference is the inital '/' in the second argument.
Human interpretation is:
Go to http://site.com/ and 1) go to path directory 2) go to one-level
above (/../) which results in site.com again 3) go to path directory 4)
go to one-level above (..) (results site.com )5) Stay in the same
directory (.) 6) goto path 7) stay there (.)
Final result is http://www.site.com/path/
The RFC (1808) suggests the following.
urlparse.urljoin('http://a/b/c/d','/./g') = <URL:http://a/./g\>
The argument is taken as a complete path for the server.
The way to use this would be, this way:
This is not a bug and can be closed.
orsenthil commentedon May 16, 2008
Btw, Thank you for the exciting report monk.e.boy. :-)
There are many hidden in urlparse,urllib*. I hope you will have fun time
finding them (and fixing them too :)
And one general comment. If the bug is valid, Python official
Documentation cannot be made to reference a blog site. Instead, a patch
to fix the python doc would itself be welcome.
facundobatista commentedon May 21, 2008
Not a bug...