diff options
author | Morris Jobke <hey@morrisjobke.de> | 2019-03-14 23:30:50 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-14 23:30:50 +0100 |
commit | 5d2edc4a22f1b61185a386faf2e2bfa97b843f0e (patch) | |
tree | 940656a65e4495d293501f564e8e3c0d28b09348 /apps/files | |
parent | bfe2c19512fb4e5b4c545e2a0a2aee3409ca0274 (diff) | |
parent | 37b1a9c4ea73ac2a9a49f306731a204caa33c44a (diff) | |
download | nextcloud-server-5d2edc4a22f1b61185a386faf2e2bfa97b843f0e.tar.gz nextcloud-server-5d2edc4a22f1b61185a386faf2e2bfa97b843f0e.zip |
Merge pull request #14686 from nextcloud/bugfix/noid/fix-hardcoded-f-url-handling
Add correct method for hardcoded `/f/{fileid}`
Diffstat (limited to 'apps/files')
-rw-r--r-- | apps/files/lib/Controller/ViewController.php | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php index fc0fb120cfe..9f9cd0b33c1 100644 --- a/apps/files/lib/Controller/ViewController.php +++ b/apps/files/lib/Controller/ViewController.php @@ -32,6 +32,7 @@ use OCA\Files\Activity\Helper; use OCP\AppFramework\Controller; use OCP\AppFramework\Http\ContentSecurityPolicy; use OCP\AppFramework\Http\RedirectResponse; +use OCP\AppFramework\Http\Response; use OCP\AppFramework\Http\TemplateResponse; use OCP\App\IAppManager; use OCP\Files\Folder; @@ -132,6 +133,18 @@ class ViewController extends Controller { * @NoCSRFRequired * @NoAdminRequired * + * @param string $fileid + * @return TemplateResponse|RedirectResponse + */ + 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); + } + + /** + * @NoCSRFRequired + * @NoAdminRequired + * * @param string $dir * @param string $view * @param string $fileid @@ -140,7 +153,7 @@ class ViewController extends Controller { public function index($dir = '', $view = '', $fileid = null, $fileNotFound = false) { if ($fileid !== null) { try { - return $this->showFile($fileid); + return $this->redirectToFile($fileid); } catch (NotFoundException $e) { return new RedirectResponse($this->urlGenerator->linkToRoute('files.view.index', ['fileNotFound' => true])); } @@ -285,7 +298,7 @@ class ViewController extends Controller { * @return RedirectResponse redirect response or not found response * @throws \OCP\Files\NotFoundException */ - private function showFile($fileId) { + private function redirectToFile($fileId) { $uid = $this->userSession->getUser()->getUID(); $baseFolder = $this->rootFolder->getUserFolder($uid); $files = $baseFolder->getById($fileId); |