We are using private browsing, filesystem and web page encoding: UTF-8
The problem occured ONLY if filename start special Hungarian characters: é, É, á, Á, ű, Ű, ő, Ő, ú, Ú, ó, Ó, ü, Ü, ö, Ö, í, Í. These characters appear in the browser well.
I get access denied, when trying download file.

Please help.

Comments

Breakerandi’s picture

I Have also problems with special characters. The File can not be downloaded because of a wrong address

Gozi’s picture

StatusFileSize
new1.63 KB

I found the reason of the problem: that standard PHP function basename() is not safe. If filenames start with non-latin characters: all of them had been stripping.

chx ( http://drupal.org/user/9446 ) has created a replacement for basename().

Code is:

function safe_basename($path,$prefix = '') {
$path = preg_replace('|^.+[\\/]|', '', $path);
if ($prefix) {
$path = preg_replace('|'. preg_quote($prefix) .'$|', '', $path);
}
return $path;
}

More info: http://drupal.org/node/278425

Patch for 6.x-2.x-dev version only!

Gozi’s picture

StatusFileSize
new1.63 KB
new1.63 KB

Corrected and updated patch.

Gozi’s picture

The early pasted and linked chx's safe baseneme function (http://drupal.org/node/278425) not fully compatible the original basename. I wrote own UTF-8 safe basename function, that works great with filebrowser.module.

function basename_safe($path) {
        $path = rtrim($path,'/');
        $path = explode('/',$path);
        return end($path);
}

If you applied previous patch, replace filebrowser_basename function with this.

Yoran’s picture

Status: Active » Fixed

Thank you for this ! I added your last function and it works perfectly. It's in dev now.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.