From e06065b4f80d7682aa57d6fc5871c2d6384ca4b8 Mon Sep 17 00:00:00 2001 From: Petr Skoda Date: Thu, 10 May 2012 22:22:11 +0200 Subject: [PATCH] MDL-31558 add missing mimetype to send_temp_file() backported from master --- lib/filelib.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/filelib.php b/lib/filelib.php index 47c7cbdc018..9e306e6caae 100644 --- a/lib/filelib.php +++ b/lib/filelib.php @@ -1617,6 +1617,13 @@ function prepare_file_content_sending() { function send_temp_file($path, $filename, $pathisstring=false) { global $CFG; + if (check_browser_version('Firefox', '1.5')) { + // only FF is known to correctly save to disk before opening... + $mimetype = mimeinfo('type', $filename); + } else { + $mimetype = 'application/x-forcedownload'; + } + // close session - not needed anymore @session_get_instance()->write_close(); @@ -1649,6 +1656,13 @@ function send_temp_file($path, $filename, $pathisstring=false) { } header('Accept-Ranges: none'); // Do not allow byteserving + if ($mimetype === 'text/plain') { + // there is no encoding specified in text files, we need something consistent + header('Content-Type: text/plain; charset=utf-8'); + } else { + header('Content-Type: '.$mimetype); + } + //flush the buffers - save memory and disable sid rewrite // this also disables zlib compression prepare_file_content_sending();