Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URL path starting with double-slash can never been matched #509

Closed
raptium opened this issue May 9, 2012 · 1 comment
Closed

URL path starting with double-slash can never been matched #509

raptium opened this issue May 9, 2012 · 1 comment

Comments

@raptium
Copy link

raptium commented May 9, 2012

URLs like http://www.example.com//haha (note there are 2 slashes) will never been matched and always get a HTTP 404 error.

at httpserver.py around line 394

scheme, netloc, path, query, fragment = urlparse.urlsplit(native_str(uri))
self.path = path
self.query = query
arguments = parse_qs_bytes(query)

tornado.web.httpserver.HTTPRequest gets its path attribute from the result of urlparse.urlsplit(), however urlsplit returns an empty path if the uri starts with 2 slashes.

>>> uri = '/haha?a=b&c=d'
>>> print urlsplit(uri)
SplitResult(scheme='', netloc='', path='/haha', query='a=b&c=d', fragment='')
>>> uri = '//haha?a=b&c=d'
>>> print urlsplit(uri)
SplitResult(scheme='', netloc='haha', path='', query='a=b&c=d', fragment='')
>>> 
@bdarnell
Copy link
Member

It will never match correctly, but paths starting with two slashes can sometimes match incorrectly: "//haha/" will match as if it were "/".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants