mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-25 09:23:28 +01:00
* fixed handling of + char in VFS filenames (using egw_vfs::decodePath() instead of urldecode())
This commit is contained in:
parent
57fa8b5504
commit
4cce629666
@ -85,7 +85,7 @@ class vfs_widget
|
||||
{
|
||||
if (!$value || !($stat = egw_vfs::stat($value)))
|
||||
{
|
||||
if ($value) $value = lang("File '%1' not found!",urldecode($value));
|
||||
if ($value) $value = lang("File '%1' not found!",egw_vfs::decodePath($value));
|
||||
$cell = etemplate::empty_cell();
|
||||
return true; // allow extra value;
|
||||
}
|
||||
@ -208,7 +208,7 @@ class vfs_widget
|
||||
soetemplate::add_child($cell,$sep);
|
||||
unset($sep);
|
||||
}
|
||||
$value['c'.$n] = $component !== '' ? urldecode($component) : '/';
|
||||
$value['c'.$n] = $component !== '' ? egw_vfs::decodePath($component) : '/';
|
||||
$path .= ($path != '/' ? '/' : '').$component;
|
||||
// replace id's in /apps again with human readable titles
|
||||
$path_parts = explode('/',$path);
|
||||
@ -271,7 +271,7 @@ class vfs_widget
|
||||
list($length,$maxLength,$allowPath) = $options = explode(',',$cell['size']);
|
||||
$preg = $allowPath ? '' : '/[^\\/]/'; // no slash '/' allowed, if not allowPath set
|
||||
$cell['size'] = "$length,$maxLength,$preg";
|
||||
$value = urldecode($value);
|
||||
$value = egw_vfs::decodePath($value);
|
||||
$extension_data = array('type' => $type,'allowPath' => $allowPath);
|
||||
break;
|
||||
|
||||
@ -349,7 +349,7 @@ class vfs_widget
|
||||
list($span,$class) = explode(',',$cell['span'],2);
|
||||
$class .= ($class ? ' ' : '') . ($broken ? 'vfsIsBrokenLink' : 'vfsIsLink');
|
||||
$cell['span'] = $span.','.$class;
|
||||
$cell['label'] = ($broken ? lang('Broken link') : lang('Link')).': '.urldecode(egw_vfs::readlink($path)).
|
||||
$cell['label'] = ($broken ? lang('Broken link') : lang('Link')).': '.egw_vfs::decodePath(egw_vfs::readlink($path)).
|
||||
(!$broken ? ' ('.$cell['label'].')' : '');
|
||||
}
|
||||
break;
|
||||
@ -371,7 +371,7 @@ class vfs_widget
|
||||
*/
|
||||
static function file_widget(&$value,$path,$name,$label=null)
|
||||
{
|
||||
$value = empty($label) ? urldecode(egw_vfs::basename($path)) : lang($label); // display (translated) Label or filename (if label empty)
|
||||
$value = empty($label) ? egw_vfs::decodePath(egw_vfs::basename($path)) : lang($label); // display (translated) Label or filename (if label empty)
|
||||
|
||||
$vfs_link = etemplate::empty_cell('label',$name,array(
|
||||
'size' => ','.egw_vfs::download_url($path).',,,_blank,,'.$path,
|
||||
@ -478,7 +478,7 @@ class vfs_widget
|
||||
{
|
||||
if (!egw_vfs::unlink($extension_data['path'].$file))
|
||||
{
|
||||
etemplate::set_validation_error($name,lang('Error deleting %1!',urldecode($extension_data['path'].$file)));
|
||||
etemplate::set_validation_error($name,lang('Error deleting %1!',egw_vfs::decodePath($extension_data['path'].$file)));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -486,7 +486,7 @@ class vfs_widget
|
||||
}
|
||||
elseif (!egw_vfs::unlink($extension_data['path']))
|
||||
{
|
||||
etemplate::set_validation_error($name,lang('Error deleting %1!',urldecode($extension_data['path'])));
|
||||
etemplate::set_validation_error($name,lang('Error deleting %1!',egw_vfs::decodePath($extension_data['path'])));
|
||||
}
|
||||
$loop = true;
|
||||
return false;
|
||||
@ -539,7 +539,7 @@ class vfs_widget
|
||||
}
|
||||
if (!egw_vfs::file_exists($dir = egw_vfs::dirname($path)) && !egw_vfs::mkdir($dir,null,STREAM_MKDIR_RECURSIVE))
|
||||
{
|
||||
etemplate::set_validation_error($name,lang('Error create parent directory %1!',urldecode($dir)));
|
||||
etemplate::set_validation_error($name,lang('Error create parent directory %1!',egw_vfs::decodePath($dir)));
|
||||
return false;
|
||||
}
|
||||
if (!copy($tmp_name,egw_vfs::PREFIX.$path))
|
||||
|
@ -154,7 +154,7 @@ class filemanager_ui
|
||||
}
|
||||
else
|
||||
{
|
||||
$msg .= lang('The requested path %1 is not available.',urldecode($path));
|
||||
$msg .= lang('The requested path %1 is not available.',egw_vfs::decodePath($path));
|
||||
}
|
||||
// reset lettersearch as it confuses users (they think the dir is empty)
|
||||
$content['nm']['searchletter'] = false;
|
||||
@ -283,11 +283,11 @@ class filemanager_ui
|
||||
$abs_target = $target[0] == '/' ? $target : egw_vfs::concat($content['nm']['path'],$target);
|
||||
if (!egw_vfs::stat($abs_target))
|
||||
{
|
||||
$content['nm']['msg'] = lang('Link target %1 not found!',urldecode($abs_target));
|
||||
$content['nm']['msg'] = lang('Link target %1 not found!',egw_vfs::decodePath($abs_target));
|
||||
break;
|
||||
}
|
||||
$content['nm']['msg'] = egw_vfs::symlink($target,$link) ?
|
||||
lang('Symlink to %1 created.',$target) : lang('Error creating symlink to target %1!',urldecode($target));
|
||||
lang('Symlink to %1 created.',$target) : lang('Error creating symlink to target %1!',egw_vfs::decodePath($target));
|
||||
break;
|
||||
case 'paste':
|
||||
$content['nm']['msg'] = self::action($clipboard_type.'_paste',$clipboard_files,$content['nm']['path']);
|
||||
@ -322,7 +322,7 @@ class filemanager_ui
|
||||
if ($upload_success)
|
||||
{
|
||||
$content['nm']['msg'] = count($upload_success) == 1 && !$upload_failure ? lang('File successful uploaded.') :
|
||||
lang('%1 successful uploaded.',urldecode(implode(', ',$upload_success)));
|
||||
lang('%1 successful uploaded.',implode(', ',$upload_success));
|
||||
}
|
||||
if ($upload_failure)
|
||||
{
|
||||
@ -340,11 +340,11 @@ class filemanager_ui
|
||||
$dir_is_writable = egw_vfs::is_writable($content['nm']['path']);
|
||||
}
|
||||
$content['paste_tooltip'] = $clipboard_files ? '<p><b>'.lang('%1 the following files into current directory',
|
||||
$clipboard_type=='copy'?lang('Copy'):lang('Move')).':</b><br />'.urldecode(implode('<br />',$clipboard_files)).'</p>' : '';
|
||||
$clipboard_type=='copy'?lang('Copy'):lang('Move')).':</b><br />'.egw_vfs::decodePath(implode('<br />',$clipboard_files)).'</p>' : '';
|
||||
$content['linkpaste_tooltip'] = $clipboard_files ? '<p><b>'.lang('%1 the following files into current directory',
|
||||
lang('link')).':</b><br />'.urldecode(implode('<br />',$clipboard_files)).'</p>' : '';
|
||||
lang('link')).':</b><br />'.egw_vfs::decodePath(implode('<br />',$clipboard_files)).'</p>' : '';
|
||||
$content['mailpaste_tooltip'] = $clipboard_files ? '<p><b>'.lang('Mail files').
|
||||
':</b><br />'.urldecode(implode('<br />',$clipboard_files)).'</p>' : '';
|
||||
':</b><br />'.egw_vfs::decodePath(implode('<br />',$clipboard_files)).'</p>' : '';
|
||||
$content['mailpaste_files'] = $clipboard_files;
|
||||
$content['upload_size'] = etemplate::max_upload_size_message();
|
||||
//_debug_array($content);
|
||||
@ -445,7 +445,7 @@ class filemanager_ui
|
||||
}
|
||||
else
|
||||
{
|
||||
$response->addScript("if (!confirm('".addslashes(lang('Do you want to overwrite the existing file %1?',urldecode($path)))."')) document.getElementById('$id').value='';");
|
||||
$response->addScript("if (!confirm('".addslashes(lang('Do you want to overwrite the existing file %1?',egw_vfs::decodePath($path)))."')) document.getElementById('$id').value='';");
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -642,7 +642,7 @@ class filemanager_ui
|
||||
if (preg_match('/^\/?(home|apps|)\/*$/',$path))
|
||||
{
|
||||
$errs++;
|
||||
return lang("Cautiously rejecting to remove folder '%1'!",urldecode($path));
|
||||
return lang("Cautiously rejecting to remove folder '%1'!",egw_vfs::decodePath($path));
|
||||
}
|
||||
}
|
||||
// now we use find to loop through all files and dirs: (selected only contains dirs now)
|
||||
@ -702,7 +702,7 @@ class filemanager_ui
|
||||
// an appropriate message
|
||||
egw::redirect_link('/index.php',array('menuaction'=>'filemanager.filemanager_ui.index',
|
||||
'path' => self::get_home_dir(),
|
||||
'msg' => lang('The requested path %1 is not available.',urldecode($query['path'])),
|
||||
'msg' => lang('The requested path %1 is not available.',egw_vfs::decodePath($query['path'])),
|
||||
));
|
||||
}
|
||||
$rows = $dir_is_writable = array();
|
||||
@ -788,7 +788,7 @@ class filemanager_ui
|
||||
}
|
||||
else
|
||||
{
|
||||
$GLOBALS['egw_info']['flags']['app_header'] = lang('Filemanager').': '.urldecode($query['path']);
|
||||
$GLOBALS['egw_info']['flags']['app_header'] = lang('Filemanager').': '.egw_vfs::decodePath($query['path']);
|
||||
}
|
||||
return egw_vfs::$find_total;
|
||||
}
|
||||
@ -890,7 +890,7 @@ class filemanager_ui
|
||||
}
|
||||
if (egw_vfs::rename($path,$to))
|
||||
{
|
||||
$msg .= lang('Renamed %1 to %2.',urldecode(basename($path)),urldecode(basename($to))).' ';
|
||||
$msg .= lang('Renamed %1 to %2.',egw_vfs::decodePath(basename($path)),egw_vfs::decodePath(basename($to))).' ';
|
||||
$content['old']['name'] = $content[$name];
|
||||
$path = $to;
|
||||
$content['mime'] = mime_magic::filename2mime($path); // recheck mime type
|
||||
@ -898,7 +898,7 @@ class filemanager_ui
|
||||
}
|
||||
else
|
||||
{
|
||||
$msg .= lang('Rename of %1 to %2 failed!',urldecode(basename($path)),urldecode(basename($to))).' ';
|
||||
$msg .= lang('Rename of %1 to %2 failed!',egw_vfs::decodePath(basename($path)),egw_vfs::decodePath(basename($to))).' ';
|
||||
if (egw_vfs::deny_script($to))
|
||||
{
|
||||
$msg .= lang('You are NOT allowed to upload a script!').' ';
|
||||
@ -1110,7 +1110,7 @@ class filemanager_ui
|
||||
}
|
||||
}
|
||||
$GLOBALS['egw_info']['flags']['java_script'] = "<script>window.focus();</script>\n";
|
||||
$GLOBALS['egw_info']['flags']['app_header'] = lang('Preferences').' '.urldecode($path);
|
||||
$GLOBALS['egw_info']['flags']['app_header'] = lang('Preferences').' '.egw_vfs::decodePath($path);
|
||||
|
||||
$tpl->exec('filemanager.filemanager_ui.file',$content,$sel_options,$readonlys,$preserve,2);
|
||||
}
|
||||
|
@ -61,7 +61,7 @@
|
||||
* ),
|
||||
* 'edit_id' => 'app_id',
|
||||
* 'edit_popup' => '400x300',
|
||||
* 'additional' => array( // allow one app to register sub-types,
|
||||
* 'additional' => array( // allow one app to register sub-types,
|
||||
* 'app-sub' => array( // different from 'types' approach above
|
||||
* // every value defined above
|
||||
* )
|
||||
@ -659,7 +659,7 @@ class egw_link extends solink
|
||||
if (is_array($id) && $link)
|
||||
{
|
||||
$link = $id;
|
||||
$title = $link['name'];
|
||||
$title = egw_vfs::decodePath($link['name']);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -672,7 +672,7 @@ class egw_link extends solink
|
||||
$title .= ': '.$link['type'] . ' '.egw_vfs::hsize($link['size']);
|
||||
}*/
|
||||
if (self::DEBUG) echo '<p>'.__METHOD__."('$app','$id')='$title' (file)</p>\n";
|
||||
return urldecode($title);
|
||||
return $title;
|
||||
}
|
||||
if ($app == '' || !is_array($reg = self::$app_register[$app]) || !isset($reg['title']))
|
||||
{
|
||||
|
@ -1450,7 +1450,7 @@ class egw_vfs extends vfs_stream_wrapper
|
||||
*
|
||||
* Not all chars get encoded, slashes '/' are silently removed!
|
||||
*
|
||||
* To reverse the encoding, eg. to display a filename to the user, you can use urldecode()
|
||||
* To reverse the encoding, eg. to display a filename to the user, you have to use egw_vfs::decodePath()
|
||||
*
|
||||
* @param string|array $component
|
||||
* @return string|array
|
||||
@ -1463,7 +1463,7 @@ class egw_vfs extends vfs_stream_wrapper
|
||||
/**
|
||||
* Encode a path: replacing certain chars with their urlencoded counterparts
|
||||
*
|
||||
* To reverse the encoding, eg. to display a filename to the user, you can use urldecode()
|
||||
* To reverse the encoding, eg. to display a filename to the user, you have to use egw_vfs::decodePath()
|
||||
*
|
||||
* @param string $path
|
||||
* @return string
|
||||
@ -1473,6 +1473,19 @@ class egw_vfs extends vfs_stream_wrapper
|
||||
return implode('/',self::encodePathComponent(explode('/',$path)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode a path: rawurldecode(): mostly urldecode(), but do NOT decode '+', as we're NOT encoding it!
|
||||
*
|
||||
* Used eg. to translate a path for displaying to the User.
|
||||
*
|
||||
* @param string $path
|
||||
* @return string
|
||||
*/
|
||||
static public function decodePath($path)
|
||||
{
|
||||
return rawurldecode($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise our static vars
|
||||
*/
|
||||
|
@ -153,7 +153,7 @@ class filesystem_stream_wrapper implements iface_stream_wrapper
|
||||
}
|
||||
|
||||
// open the "real" file
|
||||
if (!($this->opened_stream = fopen($path=urldecode(parse_url($url,PHP_URL_PATH)),$mode,$options)))
|
||||
if (!($this->opened_stream = fopen($path=egw_vfs::decodePath(parse_url($url,PHP_URL_PATH)),$mode,$options)))
|
||||
{
|
||||
if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) fopen('$path','$mode',$options) returned false!");
|
||||
return false;
|
||||
@ -295,7 +295,7 @@ class filesystem_stream_wrapper implements iface_stream_wrapper
|
||||
*/
|
||||
static function unlink ( $url )
|
||||
{
|
||||
$path = urldecode(parse_url($url,PHP_URL_PATH));
|
||||
$path = egw_vfs::decodePath(parse_url($url,PHP_URL_PATH));
|
||||
|
||||
// check access rights (file need to exist and directory need to be writable
|
||||
if (!file_exists($path) || is_dir($path) || !egw_vfs::check_access(egw_vfs::dirname($url),egw_vfs::WRITABLE))
|
||||
@ -355,7 +355,7 @@ class filesystem_stream_wrapper implements iface_stream_wrapper
|
||||
if (self::LOG_LEVEL) error_log(__METHOD__."($url_to,$url_from) can't unlink existing $url_to!");
|
||||
return false;
|
||||
}
|
||||
return rename(urldecode($from['path']),urldecode($to['path']));
|
||||
return rename(egw_vfs::decodePath($from['path']),egw_vfs::decodePath($to['path']));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -371,7 +371,7 @@ class filesystem_stream_wrapper implements iface_stream_wrapper
|
||||
*/
|
||||
static function mkdir ( $url, $mode, $options )
|
||||
{
|
||||
$path = urldecode(parse_url($url,PHP_URL_PATH));
|
||||
$path = egw_vfs::decodePath(parse_url($url,PHP_URL_PATH));
|
||||
$recursive = (bool)($options & STREAM_MKDIR_RECURSIVE);
|
||||
|
||||
// find the real parent (might be more then one level if $recursive!)
|
||||
@ -403,7 +403,7 @@ class filesystem_stream_wrapper implements iface_stream_wrapper
|
||||
*/
|
||||
static function rmdir ( $url, $options )
|
||||
{
|
||||
$path = urldecode(parse_url($url,PHP_URL_PATH));
|
||||
$path = egw_vfs::decodePath(parse_url($url,PHP_URL_PATH));
|
||||
$parent = dirname($path);
|
||||
|
||||
// check access rights (in real filesystem AND by mount perms)
|
||||
@ -425,7 +425,7 @@ class filesystem_stream_wrapper implements iface_stream_wrapper
|
||||
*/
|
||||
static function touch($url,$time=null,$atime=null)
|
||||
{
|
||||
$path = urldecode(parse_url($url,PHP_URL_PATH));
|
||||
$path = egw_vfs::decodePath(parse_url($url,PHP_URL_PATH));
|
||||
$parent = dirname($path);
|
||||
|
||||
// check access rights (in real filesystem AND by mount perms)
|
||||
@ -492,7 +492,7 @@ class filesystem_stream_wrapper implements iface_stream_wrapper
|
||||
|
||||
$this->opened_dir = null;
|
||||
|
||||
$path = urldecode(parse_url($this->opened_dir_url = $url,PHP_URL_PATH));
|
||||
$path = egw_vfs::decodePath(parse_url($this->opened_dir_url = $url,PHP_URL_PATH));
|
||||
|
||||
// ToDo: check access rights
|
||||
|
||||
@ -533,7 +533,7 @@ class filesystem_stream_wrapper implements iface_stream_wrapper
|
||||
static function url_stat ( $url, $flags )
|
||||
{
|
||||
$parts = parse_url($url);
|
||||
$path = urldecode($parts['path']);
|
||||
$path = egw_vfs::decodePath($parts['path']);
|
||||
|
||||
$stat = @stat($path); // suppressed the stat failed warnings
|
||||
|
||||
@ -733,20 +733,20 @@ class filesystem_stream_wrapper implements iface_stream_wrapper
|
||||
list(,$query) = explode('?',$url,2);
|
||||
parse_str($query,$get);
|
||||
if (empty($get['url'])) return false; // no download url given for this mount-point
|
||||
|
||||
|
||||
if (!($mount_url = egw_vfs::mount_url($url))) return false; // no mount url found, should not happen
|
||||
list($mount_url) = explode('?',$mount_url);
|
||||
|
||||
|
||||
list($url,$query) = explode('?',$url,2);
|
||||
$relpath = substr($url,strlen($mount_url));
|
||||
|
||||
|
||||
$download_url = egw_vfs::concat($get['url'],$relpath);
|
||||
if ($download_url[0] == '/')
|
||||
{
|
||||
$download_url = ($_SERVER['HTTPS'] ? 'https://' : 'http://').
|
||||
$_SERVER['HTTP_HOST'].$download_url;
|
||||
}
|
||||
|
||||
|
||||
//die(__METHOD__."('$url') --> relpath = $relpath --> $download_url");
|
||||
return $download_url;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user