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

parse_request_uri() incorrectly parses URI which contains :// (patch included) #1386

Closed
ghost opened this issue Oct 23, 2015 · 1 comment
Closed

Comments

@ghost
Copy link

ghost commented Oct 23, 2015

Originally reported by: yitezhan (Bitbucket: yitezhan, GitHub: yitezhan)


wsgiserver2.py HTTPRequest's parse_request_uri() method has a bug:

If the incoming uri has the "://" mark inside but is not a valid schema, such as "/operation/sch://foo/bar", parse_request_uri() will return scheme, authority, path = ('/operation/sch', 'foo', '/bar'), which is incorrect, and so then the dispatcher fails to find the correct handler. For this case, parse_request_uri() should return (None, None, '/operation/sch://foo/bar')

The current way of deciding the scheme looks sketchy.

i = uri.find('://')

It is probably better to use urlparse to parse the uri.

scheme, authority, path, params, query, fragment = urlparse.urlparse(uri)

The attached fix solves the issue and does not bring regression. I also modified wsgiserver3.py.


@jaraco
Copy link
Member

jaraco commented May 1, 2016

Fix released in 5.3.0.

@jaraco jaraco closed this as completed May 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant