fix: add fallback to raw path info

Follow up to https://github.com/nextcloud/server/pull/56843

The raw path info method has no fallback for an empty array parameter

Signed-off-by: Anna Larch <anna@nextcloud.com>
This commit is contained in:
Anna Larch 2026-03-09 22:22:08 +01:00 committed by backportbot[bot]
parent 20dc719970
commit 349120b43b
2 changed files with 63 additions and 1 deletions

View file

@ -723,7 +723,7 @@ class Request implements \ArrayAccess, \Countable, IRequest {
$requestUri = substr($requestUri, 0, $pos);
}
$scriptName = $this->server['SCRIPT_NAME'];
$scriptName = $this->server['SCRIPT_NAME'] ?? '';
$pathInfo = $requestUri;
// strip off the script name's dir and file name

View file

@ -1614,6 +1614,68 @@ class RequestTest extends \Test\TestCase {
];
}
public function testGetRawPathInfoWithoutScriptName(): void {
$request = new Request(
[
'server' => [
'REQUEST_URI' => '/index.php/apps/files/',
]
],
$this->requestId,
$this->config,
$this->csrfTokenManager,
$this->stream
);
$this->assertSame('index.php/apps/files/', $request->getRawPathInfo());
}
public function testGetPathInfoWithoutScriptName(): void {
$request = new Request(
[
'server' => [
'REQUEST_URI' => '/index.php/apps/files/',
]
],
$this->requestId,
$this->config,
$this->csrfTokenManager,
$this->stream
);
$this->assertSame('index.php/apps/files/', $request->getPathInfo());
}
public function testGetRawPathInfoWithoutScriptNameRoot(): void {
$request = new Request(
[
'server' => [
'REQUEST_URI' => '/',
]
],
$this->requestId,
$this->config,
$this->csrfTokenManager,
$this->stream
);
$this->assertSame('', $request->getRawPathInfo());
}
public function testGetRawPathInfoWithoutScriptNameOrRequestUri(): void {
$request = new Request(
[
'server' => []
],
$this->requestId,
$this->config,
$this->csrfTokenManager,
$this->stream
);
$this->assertSame('', $request->getRawPathInfo());
}
public function testGetRequestUriWithoutOverwrite(): void {
$this->config
->expects($this->once())