]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix utf8 filenames in ie download response header according to rfc5987, see http...
authorJörn Friedrich Dreyer <jfd@butonic.de>
Mon, 17 Dec 2012 15:23:12 +0000 (16:23 +0100)
committerJörn Friedrich Dreyer <jfd@butonic.de>
Mon, 17 Dec 2012 15:46:07 +0000 (16:46 +0100)
apps/files/download.php
lib/files.php

index 6475afb56e07636c395d42ad9769421779036fcd..e2149cd41350df0eca92346d5eca1ffd9611be25 100644 (file)
@@ -40,7 +40,12 @@ if(!OC_Filesystem::file_exists($filename)) {
 $ftype=OC_Filesystem::getMimeType( $filename );
 
 header('Content-Type:'.$ftype);
-header('Content-Disposition: attachment; filename="'.basename($filename).'"');
+if ( preg_match( "/MSIE/", $_SERVER["HTTP_USER_AGENT"] ) ) {
+       header( 'Content-Disposition: attachment; filename="' . rawurlencode( basename($filename) ) . '"' );
+} else {
+       header( 'Content-Disposition: attachment; filename*=UTF-8\'\'' . rawurlencode( basename($filename) )
+                                                                                . '; filename="' . rawurlencode( basename($filename) ) . '"' );
+}
 OCP\Response::disableCaching();
 header('Content-Length: '.OC_Filesystem::filesize($filename));
 
index 152ed8f34a7471bfc3015222c7df60cd5940cf7b..f8bae778ed2851056fa48262e4dfa3e548308e6f 100644 (file)
@@ -197,7 +197,12 @@ class OC_Files {
                }
                OC_Util::obEnd();
                if($zip or OC_Filesystem::is_readable($filename)) {
-                       header('Content-Disposition: attachment; filename="'.basename($filename).'"');
+                       if ( preg_match( "/MSIE/", $_SERVER["HTTP_USER_AGENT"] ) ) {
+                               header( 'Content-Disposition: attachment; filename="' . rawurlencode( basename($filename) ) . '"' );
+                       } else {
+                               header( 'Content-Disposition: attachment; filename*=UTF-8\'\'' . rawurlencode( basename($filename) )
+                                                                                                        . '; filename="' . rawurlencode( basename($filename) ) . '"' );
+                       }
                        header('Content-Transfer-Encoding: binary');
                        OC_Response::disableCaching();
                        if($zip) {