From 5e0f103455bafc8469c2aaed54ddea3328bb80ed Mon Sep 17 00:00:00 2001 From: creesch Date: Fri, 2 Jan 2015 16:42:47 +0100 Subject: [PATCH] replace unescape() with decodeURIComponent In 3.1 will also do encode. This ensures a smooth transition. --- modules/config.js | 20 ++++++++++---------- modules/macros.js | 2 +- modules/modbar.js | 8 ++++---- modules/removalreasons.js | 6 +++--- modules/usernotes.js | 2 +- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/modules/config.js b/modules/config.js index 69a25a4..4b2e77c 100644 --- a/modules/config.js +++ b/modules/config.js @@ -113,10 +113,10 @@ tbconfig.init = function () { \ \ Header:\ - \ + \ \ Footer:\ - \ + \ \ ', footer: '' @@ -362,7 +362,7 @@ tbconfig.init = function () { var i = 0; $(config.removalReasons.reasons).each(function () { - var label = unescape(this.text); + var label = decodeURIComponent(this.text); if (label == '') { label = '(no reason)'; } else { @@ -372,7 +372,7 @@ tbconfig.init = function () { label = TBUtils.htmlEncode(label); } - var removalReasonText = unescape(config.removalReasons.reasons[i].text) || '', + var removalReasonText = decodeURIComponent(config.removalReasons.reasons[i].text) || '', removalReasonTitle = config.removalReasons.reasons[i].title || '', removalReasonFlairText = config.removalReasons.reasons[i].flairText || '', removalReasonFlairCSS = config.removalReasons.reasons[i].flairCSS || ''; @@ -424,7 +424,7 @@ tbconfig.init = function () { if (config.modMacros && config.modMacros.length > 0) { $(config.modMacros).each(function (i, item) { - var label = unescape(item.text); + var label = decodeURIComponent(item.text); if (label == '') { label = '(no macro)'; } else { @@ -433,7 +433,7 @@ tbconfig.init = function () { } label = TBUtils.htmlEncode(label); } - var modMacroText = unescape(config.modMacros[i].text) || '', + var modMacroText = decodeURIComponent(config.modMacros[i].text) || '', modMacroTitle = config.modMacros[i].title || ''; var modMacroTemplate = '\ @@ -597,7 +597,7 @@ tbconfig.init = function () { $removalContent = $this.closest('td.removal-reasons-content'), reasonsNum = $removalContent.attr('data-reason'); - $removalContent.find('.edit-area').val(unescape(config.removalReasons.reasons[reasonsNum].text) || '(no macro)'); + $removalContent.find('.edit-area').val(decodeURIComponent(config.removalReasons.reasons[reasonsNum].text) || '(no macro)'); $removalContent.find('input[name=removal-title]').val(config.removalReasons.reasons[reasonsNum].title || ''); $removalContent.find('input[name=flair-text]').val(config.removalReasons.reasons[reasonsNum].flairText || ''); $removalContent.find('input[name=flair-css]').val(config.removalReasons.reasons[reasonsNum].flairCSS || ''); @@ -636,7 +636,7 @@ tbconfig.init = function () { delete TBUtils.configCache[subreddit]; // should this use TBUtils.clearCache? I'm not clear on what this does. -al } - var label = unescape(reasonText); + var label = decodeURIComponent(reasonText); if (label == '') { label = '(no reason)'; } else { @@ -779,7 +779,7 @@ tbconfig.init = function () { $macroContent = $this.closest('td.mod-macros-content'), reasonsNum = $macroContent.attr('data-macro'); - $macroContent.find('.edit-area').val(unescape(config.modMacros[reasonsNum].text) || '(no macro)'); + $macroContent.find('.edit-area').val(decodeURIComponent(config.modMacros[reasonsNum].text) || '(no macro)'); $macroContent.find('input[name=macro-title]').val(config.modMacros[reasonsNum].title || ''); $macroContent.find('input[name=edit-note]').val(''); @@ -810,7 +810,7 @@ tbconfig.init = function () { delete TBUtils.configCache[subreddit]; // should this use TBUtils.clearCache? I'm not clear on what this does. -al } - var label = unescape(macroText); + var label = decodeURIComponent(macroText); if (label == '') { label = '(no macro)'; diff --git a/modules/macros.js b/modules/macros.js index 1effa88..ceb2486 100644 --- a/modules/macros.js +++ b/modules/macros.js @@ -206,7 +206,7 @@ macros.init = function macrosInit() { if (!macroConfig) return; var $this = $(this), - comment = unescape($this.val()), + comment = decodeURIComponent($this.val()), topLevel = (e.target.className === 'tb-top-macro-select'), info; // disable the select box to prevent a mess with creating multiple popup boxes. diff --git a/modules/modbar.js b/modules/modbar.js index 74add0c..a5f7fd2 100644 --- a/modules/modbar.js +++ b/modules/modbar.js @@ -225,7 +225,7 @@ if (unmoderatedOn) { // Append shortcuts $.each(shortcuts, function (index, value) { - var shortcut = $('- ' + TBUtils.htmlEncode(unescape(index)) + ' '); + var shortcut = $('- ' + TBUtils.htmlEncode(decodeURIComponent(index)) + ' '); $(shortcut).appendTo('#tb-toolbarshortcuts'); }); @@ -344,7 +344,7 @@ if (unmoderatedOn) {
\

\ Import/export toolbox settings to a wiki page:
\ - \ + \ \ \ Important: This will reload the page without saving!\ @@ -414,7 +414,7 @@ if (unmoderatedOn) { } else { $.each(shortcuts, function (index, value) { - shortcutinput = ' \ + shortcutinput = ' \ \

'; //console.log(shortcutinput); @@ -460,7 +460,7 @@ See the License for the specific language governing permissions and limitations $(htmlabout).appendTo('.tb-window-content').hide(); $('About').appendTo('.tb-window-tabs'); - // $("input[name=shortcuts]").val(unescape(shortcuts)); + // $("input[name=shortcuts]").val(decodeURIComponent(shortcuts)); } $body.on('click', '.tb-settings-import, .tb-settings-export', function (e) { diff --git a/modules/removalreasons.js b/modules/removalreasons.js index 9c78cd0..31f6aeb 100644 --- a/modules/removalreasons.js +++ b/modules/removalreasons.js @@ -172,8 +172,8 @@ removal.register_setting('reasonAsSub', { // Add additional data that is found in the wiki JSON. // Any HTML needs to me unescaped, because we store it escaped in the wiki. data.logReason = response.logreason || ''; - data.header = unescape(response.header || ''); - data.footer = unescape(response.footer || ''); + data.header = decodeURIComponent(response.header || ''); + data.footer = decodeURIComponent(response.footer || ''); data.logSub = response.logsub || ''; data.logTitle = response.logtitle || DEFAULT_LOG_TITLE; data.banTitle = response.bantitle || DEFAULT_BAN_TITLE; @@ -182,7 +182,7 @@ removal.register_setting('reasonAsSub', { data.reasons = []; $(response.reasons).each(function () { data.reasons.push({ - text: unescape(this.text), + text: decodeURIComponent(this.text), title: this.title, flairText: this.flairText, flairCSS: this.flairCSS diff --git a/modules/usernotes.js b/modules/usernotes.js index ca73805..edce5e5 100644 --- a/modules/usernotes.js +++ b/modules/usernotes.js @@ -380,7 +380,7 @@ usernotes.init = function () { // We stopped using encode()d notes in v4 notes.users.forEach(function (user) { user.notes.forEach(function (note) { - note.note = unescape(note.note); + note.note = decodeURIComponent(note.note); }); }); return notes;