egw.(de|en)codePath to correctly encode % and #

This commit is contained in:
Ralf Becker 2019-03-21 12:46:22 +01:00
parent 948e22f5e5
commit 932979e553

View File

@ -7,7 +7,6 @@
* @link http://www.egroupware.org * @link http://www.egroupware.org
* @author Andreas Stöckel (as AT stylite.de) * @author Andreas Stöckel (as AT stylite.de)
* @author Ralf Becker <RalfBecker@outdoor-training.de> * @author Ralf Becker <RalfBecker@outdoor-training.de>
* @version $Id$
*/ */
/*egw:uses /*egw:uses
@ -171,7 +170,14 @@ egw.extend('utils', egw.MODULE_GLOBAL, function()
* @return {string} * @return {string}
*/ */
decodePath: function(_path) { decodePath: function(_path) {
return decodeURIComponent(_path); try {
return decodeURIComponent(_path);
}
catch(e) {
// ignore decoding errors, as they usually only mean _path is not encoded
egw.debug("error", "decodePath('"+_path+"'): "+e.stack);
}
return _path;
}, },
/** /**
@ -192,7 +198,7 @@ egw.extend('utils', egw.MODULE_GLOBAL, function()
/** /**
* Encode vfs special chars removing / * Encode vfs special chars removing /
* *
* //'%' => '%25', // % should be encoded, but easily leads to double encoding, therefore better NOT encodig it * '%' => '%25',
* '#' => '%23', * '#' => '%23',
* '?' => '%3F', * '?' => '%3F',
* '/' => '', // better remove it completly * '/' => '', // better remove it completly
@ -201,7 +207,7 @@ egw.extend('utils', egw.MODULE_GLOBAL, function()
* @return {string} * @return {string}
*/ */
encodePathComponent: function(_comp) { encodePathComponent: function(_comp) {
return _comp.replace(/#/g,'%23').replace(/\?/g,'%3F').replace(/\//g,''); return _comp.replace(/%/g,'%25').replace(/#/g,'%23').replace(/\?/g,'%3F').replace(/\//g,'');
}, },
/** /**