Skip to content

New request parser breaks on local host names #538

Open
@akadlec

Description

@akadlec

I'm using react/http on my local server which is creating server to interact with HomeKit. And the latest version break parsing incoming request because of host name.

Data which are sent by HomeKit to my server may look like this:

POST /pair-verify HTTP/1.1\r\n
Host: HomeKit\032Integration\0322509EB._hap._tcp.local\r\n
Content-Length: 37\r\n
Content-Type: application/pairing+tlv8\r\n
\r\n
\x06\x01\x01\x03 … \xE73o\xE1\xE0o\x82\xB6\xE1\x17

And this data are taken by RequestHeaderParser to parse -> ServerRequest -> new Uri and here it crashes:

if ($parts === false || (isset($parts['scheme']) && !\preg_match('#^[a-z]+$#i', $parts['scheme'])) || (isset($parts['host']) && \preg_match('#[\s_%+]#', $parts['host']))) {
                throw new \InvalidArgumentException('Invalid URI given');
}

because the uri is: http://HomeKit\032Integration\0322509EB._hap._tcp.local/pair-verify

Metadata

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