[BUGFIX] Fix Content-Disposition header sent by dumpFileContents 99/28399/3
authorFrans Saris <franssaris@gmail.com>
Fri, 14 Mar 2014 19:53:40 +0000 (20:53 +0100)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Fri, 14 Mar 2014 22:17:40 +0000 (23:17 +0100)
This patch changes the Content-Disposition header so it is also
send when $asDownload isn't set with value inline and the filename
is between quotes.

Resolves: #56923
Releases: 6.2
Change-Id: Ic47c7d3743e7bac73936d20addbc61193e6fd49c
Reviewed-on: https://review.typo3.org/28399
Reviewed-by: Philipp Gampe
Tested-by: Philipp Gampe
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind
typo3/sysext/core/Classes/Resource/ResourceStorage.php

index c2b889c..b014d35 100644 (file)
@@ -1443,15 +1443,14 @@ class ResourceStorage {
         * clears output buffer first and sends headers accordingly.
         *
         * @param FileInterface $file
-        * @param boolean $asDownload If set Content-Disposition headers are sent
+        * @param boolean $asDownload If set Content-Disposition attachment is sent, inline otherwise
         * @param string $alternativeFilename the filename for the download (if $asDownload is set)
         * @return void
         */
        public function dumpFileContents(FileInterface $file, $asDownload = FALSE, $alternativeFilename = NULL) {
-               if ($asDownload) {
-                       $downloadName = $alternativeFilename ?: $file->getName();
-                       header('Content-Disposition: attachment; filename=' . $downloadName);
-               }
+               $downloadName = $alternativeFilename ?: $file->getName();
+               $contentDisposition = $asDownload ? 'attachment' : 'inline';
+               header('Content-Disposition: ' . $contentDisposition . '; filename="' . $downloadName . '"');
                header('Content-Type: ' . $file->getMimeType());
                header('Content-Length: ' . $file->getSize());