Skip to content

[HttpFoundation]: Absolute Request Uri with default port #29234

Closed
@nkl1996

Description

@nkl1996

Symfony version(s) affected: tested on 3.4.18

Description :

A request with a absolute request uri and the default port results in a wrong interpreted request uri.

http://localhost:80/main gets interpreted as http://localhost/:80/main

Here is the code that filters the scheme and http host out of the absolute request uri. The problem is that the function getHttpHost only returns the port if its not the default one.

$requestUri = $this->server->get('REQUEST_URI');
// HTTP proxy reqs setup request URI with scheme and host [and port] + the URL path, only use URL path
$schemeAndHttpHost = $this->getSchemeAndHttpHost();
if (0 === strpos($requestUri, $schemeAndHttpHost)) {
$requestUri = substr($requestUri, \strlen($schemeAndHttpHost));
}

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