diff --git a/core/modules/system/src/FileDownloadController.php b/core/modules/system/src/FileDownloadController.php index 65ad3de..0e15cb2 100644 --- a/core/modules/system/src/FileDownloadController.php +++ b/core/modules/system/src/FileDownloadController.php @@ -52,11 +52,17 @@ public function download(Request $request, $scheme = 'private') { // Let other modules provide headers and controls access to the file. $headers = $this->moduleHandler()->invokeAll('file_download', array($uri)); - if (in_array(-1, $headers) || empty($headers)) { - throw new AccessDeniedHttpException(); + foreach ($headers as $result) { + if ($result == -1) { + throw new AccessDeniedHttpException(); + } } - return new BinaryFileResponse($uri, 200, $headers, $scheme !== 'private'); + if (count($headers)) { + return new BinaryFileResponse($uri, 200, $headers, $scheme !== 'private'); + } + + throw new AccessDeniedHttpException(); } throw new NotFoundHttpException(); diff --git a/core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php b/core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php index 4ef189a..cc9af76 100644 --- a/core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php +++ b/core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php @@ -268,10 +268,16 @@ public function setHeader(Request $request) { return $response; } + /** + * A simple page callback that uses a plain Symfony response object. + */ public function respondWithReponse(Request $request) { return new Response('test'); } + /** + * A simple page callback that uses a CacheableResponse object. + */ public function respondWithCacheableReponse(Request $request) { return new CacheableResponse('test'); }