From 349120b43bcbdc9ffd44d540b79adbc3e1f264d5 Mon Sep 17 00:00:00 2001 From: Anna Larch Date: Mon, 9 Mar 2026 22:22:08 +0100 Subject: [PATCH] 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 --- lib/private/AppFramework/Http/Request.php | 2 +- tests/lib/AppFramework/Http/RequestTest.php | 62 +++++++++++++++++++++ 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/lib/private/AppFramework/Http/Request.php b/lib/private/AppFramework/Http/Request.php index 6978d46f2d6a6..fe1ef85fefdd6 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())