From 91bb7a3c2a6f1d749576f1bb7d81ca49eb82f5a5 Mon Sep 17 00:00:00 2001 From: Tomoya Saito Date: Fri, 2 Mar 2018 21:01:50 +0900 Subject: [PATCH] multibyte-filename-for-edge --- lib/classes/dataformat/spout_base.php | 4 ++++ lib/filelib.php | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/classes/dataformat/spout_base.php b/lib/classes/dataformat/spout_base.php index 6b0c10b..cdcc9a2 100644 --- a/lib/classes/dataformat/spout_base.php +++ b/lib/classes/dataformat/spout_base.php @@ -56,6 +56,10 @@ abstract class spout_base extends \core\dataformat\base { $this->writer->setTempFolder(make_request_directory()); } $filename = $this->filename . $this->get_extension(); + // If user is using IE or Edge, urlencode the filename so that multibyte file name will show up correctly. + if (\core_useragent::is_ie() || \core_useragent::is_edge()) { + $filename = rawurlencode($filename); + } $this->writer->openToBrowser($filename); // By default one sheet is always created, but we want to rename it when we call start_sheet(). diff --git a/lib/filelib.php b/lib/filelib.php index 53f07db..329fdeb 100644 --- a/lib/filelib.php +++ b/lib/filelib.php @@ -2115,7 +2115,7 @@ function send_temp_file($path, $filename, $pathisstring=false) { } // if user is using IE, urlencode the filename so that multibyte file name will show up correctly on popup - if (core_useragent::is_ie()) { + if (core_useragent::is_ie() || core_useragent::is_edge()) { $filename = urlencode($filename); } @@ -2263,8 +2263,8 @@ function send_file($path, $filename, $lifetime = null , $filter=0, $pathisstring $mimetype = get_mimetype_for_sending($filename); } - // if user is using IE, urlencode the filename so that multibyte file name will show up correctly on popup - if (core_useragent::is_ie()) { + // If user is using IE or Edge, urlencode the filename so that multibyte file name will show up correctly on popup. + if (core_useragent::is_ie() || core_useragent::is_edge()) { $filename = rawurlencode($filename); } -- 1.8.3.1