Public bug reported:

When we download a folder of Japanese folder name on 'Main menu ->
Create -> Files' page, the ZIP file name is corrupted as the attached
screenshot (download_folder.png).

We can fix the issue using mb_eregi_replace() function instead of
preg_replace() function as below.

---------------------------

Program file to modify:
artefact/file/downloadfolder.php

Line number to modify;
56

[ Before ]
function zip_filename_from($name) {
    $name = preg_replace('#\s+#', '_', strtolower($name));
    // \pL is used to match any letter in any alphabet 
(http://php.net/manual/en/regexp.reference.unicode.php)
    $name = preg_replace('#[^\pL0-9_\-]+#', '', $name);
    if ($name != '') {
        $name = '-' . $name;
    }
    return get_string('zipfilenameprefix', 'artefact.file') . $name . '.zip';
}

[ After ]
function zip_filename_from($name) {
    $name = preg_replace('#\s+#', '_', strtolower($name));
    // \pL is used to match any letter in any alphabet 
(http://php.net/manual/en/regexp.reference.unicode.php)
    if (!extension_loaded('mbstring')) {
        $name = preg_replace('#[^\pL0-9_\-]+#', '', $name);
    }
    else {
        $name = mb_eregi_replace('#[^\pL0-9_\-]+#', '', $name);
    }
    if ($name != '') {
        $name = '-' . $name;
    }
    return get_string('zipfilenameprefix', 'artefact.file') . $name . '.zip';
}

** Affects: mahara
     Importance: High
         Status: New

** Attachment added: "ZIP file name corruption"
   
https://bugs.launchpad.net/bugs/1840733/+attachment/5283410/+files/download_folder.png

-- 
You received this bug notification because you are a member of Mahara
Contributors, which is subscribed to Mahara.
Matching subscriptions: Subscription for all Mahara Contributors -- please ask 
on #mahara-dev or mahara.org forum before editing or unsubscribing it!
https://bugs.launchpad.net/bugs/1840733

Title:
  Zipped multibyte folder name broken

Status in Mahara:
  New

Bug description:
  When we download a folder of Japanese folder name on 'Main menu ->
  Create -> Files' page, the ZIP file name is corrupted as the attached
  screenshot (download_folder.png).

  We can fix the issue using mb_eregi_replace() function instead of
  preg_replace() function as below.

  ---------------------------

  Program file to modify:
  artefact/file/downloadfolder.php

  Line number to modify;
  56

  [ Before ]
  function zip_filename_from($name) {
      $name = preg_replace('#\s+#', '_', strtolower($name));
      // \pL is used to match any letter in any alphabet 
(http://php.net/manual/en/regexp.reference.unicode.php)
      $name = preg_replace('#[^\pL0-9_\-]+#', '', $name);
      if ($name != '') {
          $name = '-' . $name;
      }
      return get_string('zipfilenameprefix', 'artefact.file') . $name . '.zip';
  }

  [ After ]
  function zip_filename_from($name) {
      $name = preg_replace('#\s+#', '_', strtolower($name));
      // \pL is used to match any letter in any alphabet 
(http://php.net/manual/en/regexp.reference.unicode.php)
      if (!extension_loaded('mbstring')) {
          $name = preg_replace('#[^\pL0-9_\-]+#', '', $name);
      }
      else {
          $name = mb_eregi_replace('#[^\pL0-9_\-]+#', '', $name);
      }
      if ($name != '') {
          $name = '-' . $name;
      }
      return get_string('zipfilenameprefix', 'artefact.file') . $name . '.zip';
  }

To manage notifications about this bug go to:
https://bugs.launchpad.net/mahara/+bug/1840733/+subscriptions

_______________________________________________
Mailing list: https://launchpad.net/~mahara-contributors
Post to     : mahara-contributors@lists.launchpad.net
Unsubscribe : https://launchpad.net/~mahara-contributors
More help   : https://help.launchpad.net/ListHelp

Reply via email to