Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-61580

Filename garbling with multi-byte filename by using Microsoft Edge

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Duplicate
    • Icon: Minor Minor
    • None
    • 3.5, 3.6
    • Libraries
    • MOODLE_35_STABLE, MOODLE_36_STABLE

      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

            Unassigned Unassigned
            t-saito Tomoya Saito
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 10 minutes
                10m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.