If teacher upload a file with multi-byte (ex. Japanese) file name, the text garbling of file name occurs when students download the file by using the Microsoft Edge.
This issue is caused by the handling of URL encoding.
So that, I fixed some source codes.
Following patch is created from source codes of the Moodle 3.5 Development version.
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);
|
}
|
|
This suggestion may be related to MDL-51419 and MDL-59379.
Regards
- will help resolve
-
MDL-59379 With IE, Feedback answers filename is broken if multibyte character is used.
-
- Development in progress
-