diff options
author | John Molakvoæ <skjnldsv@users.noreply.github.com> | 2023-12-29 14:40:34 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-29 14:40:34 +0100 |
commit | 86575c96e39e9cc31d9c257cae1a41b2bfe36755 (patch) | |
tree | 3d1490f5cca036a494019f537213933759f259b8 /apps | |
parent | 6a63974bf5c75cee556a386e0d112a4dba3fb49d (diff) | |
parent | a66877813c4cf20088e81b3b847742fa2e210f3d (diff) | |
download | nextcloud-server-86575c96e39e9cc31d9c257cae1a41b2bfe36755.tar.gz nextcloud-server-86575c96e39e9cc31d9c257cae1a41b2bfe36755.zip |
Merge pull request #42427 from nextcloud/fix/issue-42418
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files/lib/Controller/ViewController.php | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php index be5069b7f61..8de679f25dd 100644 --- a/apps/files/lib/Controller/ViewController.php +++ b/apps/files/lib/Controller/ViewController.php @@ -237,12 +237,16 @@ class ViewController extends Controller { if ($fileid && $dir !== '') { $baseFolder = $this->rootFolder->getUserFolder($userId); $nodes = $baseFolder->getById((int) $fileid); - $nodePath = $baseFolder->getRelativePath($nodes[0]->getPath()); - $relativePath = $nodePath ? dirname($nodePath) : ''; - // If the requested path does not contain the file id - // or if the requested path is not the file id itself - if (count($nodes) === 1 && $relativePath !== $dir && $nodePath !== $dir) { - return $this->redirectToFile((int) $fileid); + if (!empty($nodes)) { + $nodePath = $baseFolder->getRelativePath($nodes[0]->getPath()); + $relativePath = $nodePath ? dirname($nodePath) : ''; + // If the requested path does not contain the file id + // or if the requested path is not the file id itself + if (count($nodes) === 1 && $relativePath !== $dir && $nodePath !== $dir) { + return $this->redirectToFile((int) $fileid); + } + } else { // fileid does not exist anywhere + $fileNotFound = true; } } |