00376: Upload URL encoding doesn't work with NTFS

Summary: Upload URL encoding doesn't work with NTFS
Created: 2005-03-09 15:06
Status: Open
Category: Bug
Assigned:
Priority: 1
Version: 2.0.beta25
OS: Win2000/Apache2/PHP5

Description: ISO-8859-1 URL encoding is fine for most systems, but not for NTFS, since NTFS uses UTF-8 internally. When you have some group name with accentuated characters in it, you get a permission denied when clicking on the image link in the upload window, and the attached image won't be displayed in the page. On NTFS systems, the image link URL should use UTF-8 encoding instead of ISO-8859-1 one.

Below is the fix I've found:

 
 ## In local/config.php
 $UseUtf8ForUploadUrl = 1;

 ## In scripts/upload.php
 function LinkUpload()
   ...
   $path = ...;
   + if ($UseUtf8ForUploadUrl)
   +   $path = mb_convert_encoding($path,"UTF-8","ISO-8859-1");

 function FmtUploadList()
   ...
   foreach($filelist as $file=>$x) {
     - $name = PUE("$uploadurl/$file");
     + if ($UseUtf8ForUploadUrl) {
     +   $name = mb_convert_encoding("$uploadurl/$file","UTF-8","ISO-8859-1");
     + } else { $name = PUE("$uploadurl/$file"); }
     ...
 

NB: MBSTRING extension should be enabled in php.ini, since the mb_convert_encoding() function is taken from it.