]> source.dussan.org Git - nextcloud-server.git/commitdiff
Properly redirect if accessing invalid file though /f/ entrypoint 16891/head
authorJulius Härtl <jus@bitgrid.net>
Tue, 18 Jun 2019 11:09:38 +0000 (13:09 +0200)
committerBackportbot <backportbot-noreply@rullzer.com>
Tue, 27 Aug 2019 16:51:00 +0000 (16:51 +0000)
Signed-off-by: Julius Härtl <jus@bitgrid.net>
apps/files/lib/Controller/ViewController.php

index 9f9cd0b33c15d2887daa01bcf509501d2c049e38..cf1b4374da4dfd6b5092ecd0720d00ff6cf69b8c 100644 (file)
@@ -31,6 +31,7 @@ namespace OCA\Files\Controller;
 use OCA\Files\Activity\Helper;
 use OCP\AppFramework\Controller;
 use OCP\AppFramework\Http\ContentSecurityPolicy;
+use OCP\AppFramework\Http\NotFoundResponse;
 use OCP\AppFramework\Http\RedirectResponse;
 use OCP\AppFramework\Http\Response;
 use OCP\AppFramework\Http\TemplateResponse;
@@ -138,7 +139,11 @@ class ViewController extends Controller {
         */
        public function showFile(string $fileid = null): Response {
                // This is the entry point from the `/f/{fileid}` URL which is hardcoded in the server.
-               return $this->redirectToFile($fileid);
+               try {
+                       return $this->redirectToFile($fileid);
+               } catch (NotFoundException $e) {
+                       return new RedirectResponse($this->urlGenerator->linkToRoute('files.view.index', ['fileNotFound' => true]));
+               }
        }
 
        /**