Merge pull request #58817 from nextcloud/fix/noid/add-fallback-to-raw-path-info

This commit is contained in:
Kate 2026-03-09 23:21:13 +01:00 committed by GitHub
commit 27c438503b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 63 additions and 1 deletions

View file

@ -717,7 +717,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())