Skip to content

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

@ghost

Description

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.


Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions