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

[bug] URL parssing error in the web server #489

Closed
ghost opened this issue Sep 3, 2015 · 2 comments
Closed

[bug] URL parssing error in the web server #489

ghost opened this issue Sep 3, 2015 · 2 comments
Assignees
Milestone

Comments

@ghost
Copy link

ghost commented Sep 3, 2015

If you run this simple server example :

import asyncio
from aiohttp import web

@asyncio.coroutine
def handle(request):
    return webResponse(body=request.path.encode('utf8'))

@asyncio.coroutine
def init(loop):
    app = web.Application(loop=loop)
    app.router.add_route('GET', '/', handle)
    srv = yield from loop.create_server(app.make_handler(), '127.0.0.1', 5555)
    return srv

loop = asyncio.get_event_loop()
loop.run_until_complete(init(loop))

try:
    loop.run_forever()
except KeyboardInterrupt:
    pass

The following requests will get a 200 OK with the considered path as content :

$ curl -X GET http://127.0.0.1:5555///
/
$ curl -X GET http://127.0.0.1:555//foo/
/

As you can see, the path of the URL is not well parsed.

This bug resides in the _splitted_path non-data descriptor which uses urlsplit on a path rather than a full URL. The consequence is a second segment interpreted as a network location if the first one is empty.

I've not quite investigated a fix at the moment, but _splitted_path only being used by raw_path and query_string seems to be a plea to use a fake scheme and netloc for urlsplit to behave the expected way.

@asvetlov asvetlov added the bug label Sep 3, 2015
@asvetlov
Copy link
Member

asvetlov commented Sep 3, 2015

I'll take a look

@asvetlov asvetlov self-assigned this Sep 3, 2015
@asvetlov asvetlov added this to the 0.18 milestone Sep 3, 2015
asvetlov added a commit that referenced this issue Sep 4, 2015
asvetlov pushed a commit that referenced this issue Sep 4, 2015
@lock
Copy link

lock bot commented Oct 29, 2019

This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue for
related bugs.

If you feel like there's important points made in this discussion,
please include those exceprts into that new issue.

@lock lock bot added the outdated label Oct 29, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant