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
bb-migration opened this Issue Oct 23, 2015 · 1 comment

Comments

2 participants
@bb-migration

bb-migration 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

This comment has been minimized.

Show comment
Hide comment
@jaraco

jaraco May 1, 2016

Member

Fix released in 5.3.0.

Member

jaraco commented May 1, 2016

Fix released in 5.3.0.

@jaraco jaraco closed this May 1, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment