diff --git a/source/Ox.UI/js/Core/Cookies.js b/source/Ox.UI/js/Core/Cookies.js index a29e374b..4da89ae7 100644 --- a/source/Ox.UI/js/Core/Cookies.js +++ b/source/Ox.UI/js/Core/Cookies.js @@ -12,7 +12,7 @@ Ox.Cookies = function() { if (document.cookie && document.cookie != '') { document.cookie.split('; ').forEach(function(cookie) { name = cookie.split('=')[0]; - value[name] = decodeURIComponent(cookie.substring(name.length + 1)); + value[name] = Ox.decodeURIComponent(cookie.substring(name.length + 1)); }); } return value; diff --git a/source/Ox.UI/js/Core/URL.js b/source/Ox.UI/js/Core/URL.js index b7a58546..a03dfa6a 100644 --- a/source/Ox.UI/js/Core/URL.js +++ b/source/Ox.UI/js/Core/URL.js @@ -563,7 +563,7 @@ Ox.URL = function(options) { } function decodeValue(value) { - return decodeURIComponent(value); + return Ox.decodeURIComponent(value); } function encodeValue(value) { diff --git a/source/Ox/js/String.js b/source/Ox/js/String.js index 8f28a701..128556a6 100644 --- a/source/Ox/js/String.js +++ b/source/Ox/js/String.js @@ -24,6 +24,24 @@ Ox.clean = function(string) { })).join('\n'); }; +/*@ +Ox.decodeURIComponent Decodes URI + Unlike window.decodeURI, this doesn't throw on trailing '%'. + (string) -> Decoded string +@*/ +Ox.decodeURI = function(string) { + return decodeURIComponent(string.replace(/%(?![0-7][0-9A-F])/g, '%25')); +}; + +/*@ +Ox.decodeURIComponent Decodes URI component + Unlike window.decodeURIComponent, this doesn't throw on trailing '%'. + (string) -> Decoded string +@*/ +Ox.decodeURIComponent = function(string) { + return decodeURIComponent(string.replace(/%(?![0-7][0-9A-F])/g, '%25')); +}; + /*@ Ox.endsWith Tests if a string ends with a given substring Equivalent to `new RegExp(Ox.escapeRegExp(substring) + '$').test(string)`.