← Back to team overview

mahara-contributors team mailing list archive

[Bug 1840733] Re: Zipped multibyte folder name broken

 

** Changed in: mahara
       Status: Fix Committed => Fix Released

-- 
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:
  Fix Released

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


References