Reviewed:  https://reviews.mahara.org/10314
Committed: 
https://git.mahara.org/mahara/mahara/commit/a2c14d3dabb9ea4f51072711f26d50147b128b91
Submitter: Robert Lyon (robe...@catalyst.net.nz)
Branch:    master

commit a2c14d3dabb9ea4f51072711f26d50147b128b91
Author: Mitsuhiro Yoshida <m...@mitstek.com>
Date:   Mon Sep 9 11:37:21 2019 +1200

Bug 1840733: fix zip filename corrupted on download

behatnotneeded

Change-Id: Ice0d3212fbb29ba43355589bfcbd05b6f79c441e

-- 
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 Committed

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