mirror of
https://github.com/nextcloud/server.git
synced 2026-03-29 13:53:55 -04:00
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:
parent
20dc719970
commit
349120b43b
2 changed files with 63 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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())
|
||||
|
|
|
|||
Loading…
Reference in a new issue