From 4b5379d61beee60072f7720cee94f2a873698f86 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 21 Mar 2019 12:36:07 +0100 Subject: [PATCH] * Filemanager/WebDAV: handle url-special chars like %, # and ? correctly --- api/js/etemplate/et2_widget_vfs.js | 21 ++++++++------------- api/src/Vfs.php | 11 +++++------ api/src/Vfs/WebDAV.php | 3 ++- filemanager/js/app.js | 16 ++++++---------- 4 files changed, 21 insertions(+), 30 deletions(-) diff --git a/api/js/etemplate/et2_widget_vfs.js b/api/js/etemplate/et2_widget_vfs.js index b1ef2c8dc5..b6d15af5b9 100644 --- a/api/js/etemplate/et2_widget_vfs.js +++ b/api/js/etemplate/et2_widget_vfs.js @@ -7,8 +7,7 @@ * @link http://www.egroupware.org * @author Nathan Gray * @copyright Nathan Gray 2012 - * @version $Id$ -*/ + */ /*egw:uses /vendor/bower-asset/jquery/dist/jquery.js; @@ -321,13 +320,6 @@ var et2_vfsPath = (function(){ "use strict"; return et2_vfsName.extend( { _value = _value.path; } - try - { - _value = egw.decodePath(_value); - } catch (e) - { - _value = 'Error! ' + _value; - } if(_value === this.options.value && this._oldValue !== et2_no_init) return; var path_parts = _value.split('/'); @@ -391,7 +383,7 @@ var et2_vfsPath = (function(){ "use strict"; return et2_vfsName.extend( } }, getValue: function() { - return egw.encodePath(this.options.value); + return this.options ? this.options.value : null; } });}).call(this); et2_register_widget(et2_vfsPath, ["vfs-path"]); @@ -959,6 +951,9 @@ var et2_vfsUpload = (function(){ "use strict"; return et2_file.extend( /** * A file upload is finished, update the UI + * + * @param {object} file + * @param {string|object} response */ finishUpload: function(file, response) { var result = this._super.apply(this, arguments); @@ -1113,7 +1108,7 @@ var et2_vfsSelect = (function(){ "use strict"; return et2_inputWidget.extend( name: "button icon", type: "string", default: "check", - description: "Custom icon to show on submit button.", + description: "Custom icon to show on submit button." }, "name": { name:"File name", @@ -1131,7 +1126,7 @@ var et2_vfsSelect = (function(){ "use strict"; return et2_inputWidget.extend( "extra_buttons": { name: "extra action buttons", type: "any", - description: "Extra buttons passed to dialog. It's co-related to method.", + description: "Extra buttons passed to dialog. It's co-related to method." } }, @@ -1298,7 +1293,7 @@ var et2_vfsSelect = (function(){ "use strict"; return et2_inputWidget.extend( var et2 = {}; if (etemplate && etemplate.name && !app[egw(window).app_name()]) { - et2 = etemplate2.getByTemplate(etemplate.name)[0] + et2 = etemplate2.getByTemplate(etemplate.name)[0]; } else { diff --git a/api/src/Vfs.php b/api/src/Vfs.php index 024409da2e..44900e1743 100644 --- a/api/src/Vfs.php +++ b/api/src/Vfs.php @@ -1,14 +1,13 @@ - * @copyright (c) 2008-16 by Ralf Becker - * @version $Id$ + * @copyright (c) 2008-19 by Ralf Becker */ namespace EGroupware\Api; @@ -1618,7 +1617,7 @@ class Vfs $zip->setArchiveComment(lang('Created by %1', $GLOBALS['egw_info']['user']['account_lid']) . ' ' .DateTime::to()); // Record total for debug, not available after close() - $total_files = $zip->numFiles; + //$total_files = $zip->numFiles; $result = $zip->close(); if(!$result || !filesize($zip_file)) @@ -1863,7 +1862,7 @@ class Vfs * @var array */ static public $encode = array( - //'%' => '%25', // % should be encoded, but easily leads to double encoding, therefore better NOT encodig it + '%' => '%25', '#' => '%23', '?' => '%3F', '/' => '', // better remove it completly diff --git a/api/src/Vfs/WebDAV.php b/api/src/Vfs/WebDAV.php index 2a0d1a4419..aecf9f6cf0 100644 --- a/api/src/Vfs/WebDAV.php +++ b/api/src/Vfs/WebDAV.php @@ -185,9 +185,10 @@ class WebDAV extends HTTP_WebDAV_Server_Filesystem } $dest = $this->base . $options["dest"]; - $destdir = dirname($dest); + $destdir = Vfs::dirname($dest); if (!file_exists($destdir) || !is_dir($destdir)) { + //error_log(__METHOD__."(".array2string($options).", $del) file_exists('$destdir')=".array2string(file_exists($destdir)).", is_dir('$destdir')=".array2string(is_dir($destdir))); return "409 Conflict"; } diff --git a/filemanager/js/app.js b/filemanager/js/app.js index 94557c7c74..e9e336e714 100644 --- a/filemanager/js/app.js +++ b/filemanager/js/app.js @@ -4,9 +4,8 @@ * @link http://www.egroupware.org * @package filemanager * @author Ralf Becker - * @copyright (c) 2008-14 by Ralf Becker + * @copyright (c) 2008-19 by Ralf Becker * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License - * @version $Id$ */ /** @@ -246,7 +245,8 @@ app.classes.filemanager = AppJS.extend( { for(etemplate_name in this.path_widget) break; } - return this.path_widget[etemplate_name] ? this.path_widget[etemplate_name].get_value() : null; + var path_widget = this.path_widget[etemplate_name]; + return path_widget ? path_widget.get_value.apply(path_widget) : null; }, /** @@ -317,10 +317,6 @@ app.classes.filemanager = AppJS.extend( } }, - - - - /** * Finish callback for file a file dialog, to get the overwrite / rename prompt * @@ -378,8 +374,8 @@ app.classes.filemanager = AppJS.extend( if (_data.uploaded[file].confirm && !_data.uploaded[file].confirmed) { var buttons = [ - {text: this.egw.lang("Yes"), id: "overwrite", class: "ui-priority-primary", "default": true, image: 'check',}, - {text: this.egw.lang("Rename"), id:"rename", image: 'edit',}, + {text: this.egw.lang("Yes"), id: "overwrite", class: "ui-priority-primary", "default": true, image: 'check'}, + {text: this.egw.lang("Rename"), id:"rename", image: 'edit'}, {text: this.egw.lang("Cancel"), id:"cancel"} ]; if (_data.uploaded[file].confirm === "is_dir") @@ -587,7 +583,7 @@ app.classes.filemanager = AppJS.extend( } } self._do_action('createdir', egw.encodePathComponent(dir), true, path); // true=synchronous request - self.change_dir((path == '/' ? '' : path)+'/'+ dir); + self.change_dir((path == '/' ? '' : path)+'/'+ egw.encodePathComponent(dir)); } },this.egw.lang('New directory'),this.egw.lang('Create directory')); },