Skip to content

Commit

Permalink
Merge pull request #15993 from nextcloud/bugfix/noid/file-not-found
Browse files Browse the repository at this point in the history
Properly redirect if accessing invalid file though /f/ entrypoint
  • Loading branch information
skjnldsv authored Jun 19, 2019
2 parents 0d7727b + 2d06ea5 commit 3a0e4a1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion apps/files/lib/Controller/ViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
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;
Expand Down Expand Up @@ -138,7 +139,11 @@ protected function getStorageInfo() {
*/
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]));
}
}

/**
Expand Down

0 comments on commit 3a0e4a1

Please sign in to comment.