Explorar el Código

Merge pull request #15993 from nextcloud/bugfix/noid/file-not-found

Properly redirect if accessing invalid file though /f/ entrypoint
tags/v17.0.0beta1
John Molakvoæ hace 4 años
padre
commit
3a0e4a1927
No account linked to committer's email address
Se han modificado 1 ficheros con 6 adiciones y 1 borrados
  1. 6
    1
      apps/files/lib/Controller/ViewController.php

+ 6
- 1
apps/files/lib/Controller/ViewController.php Ver fichero

@@ -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]));
}
}

/**

Cargando…
Cancelar
Guardar