diff --git a/lib/private/AppFramework/Http/Request.php b/lib/private/AppFramework/Http/Request.php index 7048a19b4002b..d1d5a1bb794d9 100644 --- a/lib/private/AppFramework/Http/Request.php +++ b/lib/private/AppFramework/Http/Request.php @@ -723,7 +723,7 @@ public function getRawPathInfo(): string { $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 diff --git a/tests/lib/AppFramework/Http/RequestTest.php b/tests/lib/AppFramework/Http/RequestTest.php index 7ea2cb3148230..b03a7f4efe40d 100644 --- a/tests/lib/AppFramework/Http/RequestTest.php +++ b/tests/lib/AppFramework/Http/RequestTest.php @@ -1614,6 +1614,68 @@ public static function dataPathInfo(): array { ]; } + 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())