From 672c40780494cc00bb8eca45ced7e7e67b0caa90 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 21 Mar 2019 12:46:22 +0100 Subject: [PATCH] egw.(de|en)codePath to correctly encode % and # --- api/js/jsapi/egw_utils.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/api/js/jsapi/egw_utils.js b/api/js/jsapi/egw_utils.js index e3ab6de0f2..d3af201ba0 100644 --- a/api/js/jsapi/egw_utils.js +++ b/api/js/jsapi/egw_utils.js @@ -7,7 +7,6 @@ * @link http://www.egroupware.org * @author Andreas Stöckel (as AT stylite.de) * @author Ralf Becker - * @version $Id$ */ /*egw:uses @@ -175,7 +174,14 @@ egw.extend('utils', egw.MODULE_GLOBAL, function() * @return {string} */ 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; }, /** @@ -196,7 +202,7 @@ egw.extend('utils', egw.MODULE_GLOBAL, function() /** * Encode vfs special chars removing / * - * //'%' => '%25', // % should be encoded, but easily leads to double encoding, therefore better NOT encodig it + * '%' => '%25', * '#' => '%23', * '?' => '%3F', * '/' => '', // better remove it completly @@ -205,7 +211,7 @@ egw.extend('utils', egw.MODULE_GLOBAL, function() * @return {string} */ 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,''); }, /**