aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@users.noreply.github.com>2019-06-19 10:35:14 +0200
committerGitHub <noreply@github.com>2019-06-19 10:35:14 +0200
commit3a0e4a192746e157c41453ff1892e7a415f72b49 (patch)
tree587f42545619c0fba727057f0f2cfef36a89fa59
parent0d7727bfeb35d92a8d7ab1efc4751634955f58b4 (diff)
parent2d06ea5cfc46f12c89dc50a7b73f87de350f8c0d (diff)
downloadnextcloud-server-3a0e4a192746e157c41453ff1892e7a415f72b49.tar.gz
nextcloud-server-3a0e4a192746e157c41453ff1892e7a415f72b49.zip
Merge pull request #15993 from nextcloud/bugfix/noid/file-not-found
Properly redirect if accessing invalid file though /f/ entrypoint
-rw-r--r--apps/files/lib/Controller/ViewController.php7
1 files changed, 6 insertions, 1 deletions
diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php
index 9f9cd0b33c1..cf1b4374da4 100644
--- a/apps/files/lib/Controller/ViewController.php
+++ b/apps/files/lib/Controller/ViewController.php
@@ -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]));
+ }
}
/**