Thanks to visit codestin.com
Credit goes to github.com

Skip to content

PathInfo not correct if index.php is in the path. #60773

Open
@sitepark-veltrup

Description

@sitepark-veltrup

Symfony version(s) affected

7.4

Description

The determination of PathInfo in the \Symfony\Component\HttpFoundation\Request class is not correct if the substring index.php is in the path.
I noticed this because the access control rule no longer works either.

How to reproduce

In my case, SCRIPT_FILENAME, SCRIPT_NAME and PHP_SELF are set as follows.

with index.php

$request = \Symfony\Component\HttpFoundation\Request::create('http://test.com/path/index.php.media/image.jpg');
$request->server->set('SCRIPT_FILENAME', '/var/www/test.com/public/index.php');
$request->server->set('SCRIPT_NAME', '/path/index.php.media/image.jpg');
$request->server->set('PHP_SELF', '/path/index.php.media/image.jpg');
echo $request->getPathInfo();

getPathInfo() returns edia/image.jpg

with index.phx

$request = \Symfony\Component\HttpFoundation\Request::create('http://test.com/path/index.php.media/image.jpg');
$request->server->set('SCRIPT_FILENAME', '/var/www/test.com/public/index.php');
$request->server->set('SCRIPT_NAME', '/path/index.phx.media/image.jpg');
$request->server->set('PHP_SELF', '/path/index.phx.media/image.jpg');
echo $request->getPathInfo();

getPathInfo() returns /path/index.php.media/image.jpg (as expected)

Possible Solution

No response

Additional Context

No response

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