Posted by William Haller on August 20, 2009 at 9:57pm
Jump to:
| Project: | Filebrowser |
| Version: | 6.x-2.x-dev |
| Component: | Directory Listing Pages |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
One of our illustrious users has & characters in some of their file names. I've checked the input filter type and it's set to Full HTML, which doesn't have HTML filter or HTML corrector turned on. Yet when you try to download the file, the file name path comes out with an = at the end of it like it's trying to split at the & and turn the last part of the file name into an empty CGI variable. The download fails since it can't open the weird file.
In addition, at least in konqueror, when you go to save the file the name that is automatically provided is a number rather than the file name, and that seems to be true regardless of whether there's a number in the name or not.
Comments
#1
I have workaround for filenames or dirnames with special characters:
add (in filebrowser.common.inc)
function _filebrowser_drupal_urldecode($text) {
if (variable_get('clean_url', '0')) {
// Decoded: % / & # + //
return rawurldecode(str_replace(array('%2525', '/', '%2526', '%2523', '%252B', '/%252F'),
array('%25', '%2F', '%26', '%23', '%2B', '//'),
rawurldecode($text)));
}
else {
return rawurldecode(str_replace('%2F', '/', rawurldecode($text)));
}
}
function _filebrowser_drupal_urlencode($text) {
if (variable_get('clean_url', '0')) {
// Decoded: % / & # + //
return str_replace(array('%25', '%2F', '%26', '%23', '%2B', '//'),
array('%2525', '/', '%2526', '%2523', '%252B', '/%252F'),
rawurlencode($text));
}
else {
return str_replace('%2F', '/', rawurlencode($text));
}
}
replace (in filebrowser.common.inc)$url_parts = explode('/', isset($_GET['path']) ? $_GET['path'] : '');
by
$url_parts = explode('/', isset($_GET['path']) ? _filebrowser_drupal_urldecode($_GET['path']) : '');
replace (in filebrowser.common.inc)
$file_path = array ();
if ($file_name == '..') {
$parent_folder = dirname($relative_path);
if ($parent_folder != "/") {
$file_path['path'] = $parent_folder;
}
} else {
$file_path['path'] = $relative_path . $file_name;
}
by
$file_path = array ();
if ($file_name == '..') {
$parent_folder = dirname($relative_path);
if ($parent_folder != "/") {
$file_path['path'] = _filebrowser_drupal_urlencode($parent_folder);
}
} else {
$file_path['path'] = _filebrowser_drupal_urlencode($relative_path . $file_name);
}
Workaround for active 6.x-2.x-dev version only!
#2
with the new system if file's id I had to implement to handle national characters (Japanese, Swedish, Turkish, etc.) filenames with & are normally working out of the box.
@gozi perhaps we can use your workaround in the download manager (see filebrowser_callback_download) for direct download and/or security by obscurity ?
#3