**Gerrit/Patchset: https://reviews.mahara.org/mahara refs/changes/14/10314/2
**Browser tested: Firefox
**Theme used: Default (Raw)

**DESCRIPTION/SUMMARY: 
Long multibyte i.e. Japanese email subjects are corrupted when they are 
shortened (invalid ? character inserted)

**PRECONDITIONS:
1. Mahara language packs for at least the following languages are installed: 
English (default), Japanese and Māori.
2. An existing target user with at least one folder and several files is 
present.  Their User menu Settings Preferences Language is set to English.
Note: used a user with a Home folder that had 1 Images folder and 20 files.  
The Images folder contained 3 sub-folders only - jpeg with 10 jpeg files in it, 
png with 9 png files in it and lastly other with 1 jpeg file in it.  The total 
zipped file size of the reproduced defective Japanese language file was 1.0 MB 
as was the same folder and files using English language.
       

**TEST STEPS:
Step 1: Target user is logged in, navigates to Create --> Files
Step 2: The user's Home folder contents are displayed (as described above).
Step 3: User scrolls down and selects the 'Download folder...' option & Saves 
the file
Expected result: A zip file named folder-home.zip is created in the user's 
defafult Download folder, it contains the same content as that described above 
in the Note.

Step 4: The user updates their language to Japanese (using Precondition step 2 
above) and repeats steps 1-3.
Step 5: The user updates their language to Māori (using Precondition step 2 
above) and repeats steps 1-3.

Actual result: As expected, please see the attachment. All zip files contain 
the same folders and files.
Catalyst QA testing: PASSED ✔

** Attachment added: "Pre and post fix testing zip files.png"
   
https://bugs.launchpad.net/mahara/+bug/1840733/+attachment/5293358/+files/Pre%20and%20post%20fix%20testing%20zip%20files.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:
  In Progress

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     : [email protected]
Unsubscribe : https://launchpad.net/~mahara-contributors
More help   : https://help.launchpad.net/ListHelp

Reply via email to