From 56dae9042576d7af99ce3e68ca8b2b9fb25617d4 Mon Sep 17 00:00:00 2001 From: Joshua Fontany Date: Wed, 20 Oct 2021 08:25:05 -0700 Subject: [PATCH] Fix $tw.utils.decodeURISafe and $tw.utils.decodeURIComponentSafe not available during boot process (#6107) * call self.displayError * Revert "call self.displayError" This reverts commit 5d599aa9795f9d816c55378ab6df0a1a691ceed0. * fix 5999 URI utils bug --- boot/boot.js | 22 ++++++++++++++++++++++ core/modules/utils/utils.js | 18 ------------------ 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/boot/boot.js b/boot/boot.js index 9a0af66e2..482af283c 100644 --- a/boot/boot.js +++ b/boot/boot.js @@ -256,6 +256,28 @@ $tw.utils.deepDefaults = function(object /*, sourceObjectList */) { return object; }; +/* +Convert a URIComponent encoded string to a string safely +*/ +$tw.utils.decodeURIComponentSafe = function(s) { + var v = s; + try { + v = decodeURIComponent(s); + } catch(e) {} + return v; +}; + +/* +Convert a URI encoded string to a string safely +*/ +$tw.utils.decodeURISafe = function(s) { + var v = s; + try { + v = decodeURI(s); + } catch(e) {} + return v; +}; + /* Convert "&" to &, " " to nbsp, "<" to <, ">" to > and """ to " */ diff --git a/core/modules/utils/utils.js b/core/modules/utils/utils.js index 1e6b7cec2..24e4cbd25 100644 --- a/core/modules/utils/utils.js +++ b/core/modules/utils/utils.js @@ -978,22 +978,4 @@ exports.makeCompareFunction = function(type,options) { return (types[type] || types[options.defaultType] || types.number); }; -exports.decodeURIComponentSafe = function(str) { - var value = str; - try { - value = decodeURIComponent(str); - } catch(e) { - } - return value; -}; - -exports.decodeURISafe = function(str) { - var value = str; - try { - value = decodeURI(str); - } catch(e) { - } - return value; -}; - })();