Skip to content

incorrect line splitting in HttpRequestParser #97

Closed
@tumb1er

Description

We are receiving some HTTP requests that cause an Invalid Header error in aiohttp.
That's because of an issue in splitlines in
aiohttp.procotol.HttpRequestParser:

lines = raw_data.decode(
            'ascii', 'surrogateescape').splitlines(True)

For example, this code produces 4 lines instead of 3:

>>> rd = bytearray(b'line1\r\nline2_start_\x1c_line2_end\r\nline3\r\n')
>>> rd.decode('ascii', 'surrogateescape').splitlines(True)
['line1\r\n', 'line2_start_\x1c', '_line2_end\r\n', 'line3\r\n']

In my case it was invalid user-agent header for UCBrowser, but any thoughts how to fix it?

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions