Skip to content
This repository has been archived by the owner on Jun 15, 2019. It is now read-only.

Commit

Permalink
replace unescape() with decodeURIComponent
Browse files Browse the repository at this point in the history
In 3.1 will also do encode. This ensures a smooth transition.
  • Loading branch information
creesch committed Jan 2, 2015
1 parent 0241bb8 commit 5e0f103
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
20 changes: 10 additions & 10 deletions modules/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ tbconfig.init = function () {
</td>\
</tr><tr>\
<td>Header:</td>\
<td><textarea class="edit-header" >' + TBUtils.htmlEncode(unescape(configData.removalReasons.header ? configData.removalReasons.header : '')) + '</textarea></td>\
<td><textarea class="edit-header" >' + TBUtils.htmlEncode(decodeURIComponent(configData.removalReasons.header ? configData.removalReasons.header : '')) + '</textarea></td>\
</tr><tr>\
<td>Footer:</td>\
<td><textarea class="edit-footer" >' + TBUtils.htmlEncode(unescape(configData.removalReasons.footer ? configData.removalReasons.footer : '')) + '</textarea></td>\
<td><textarea class="edit-footer" >' + TBUtils.htmlEncode(decodeURIComponent(configData.removalReasons.footer ? configData.removalReasons.footer : '')) + '</textarea></td>\
</tr>\
</table>',
footer: '<input class="save-removal-settings" type="button" value="Save removal reasons settings">'
Expand Down Expand Up @@ -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 = '<span style="color: #cecece">(no reason)</span>';
} else {
Expand All @@ -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 || '';
Expand Down Expand Up @@ -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 = '<span style="color: #cecece">(no macro)</span>';
} else {
Expand All @@ -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 = '\
Expand Down Expand Up @@ -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) || '<span style="color: #cecece">(no macro)</span>');
$removalContent.find('.edit-area').val(decodeURIComponent(config.removalReasons.reasons[reasonsNum].text) || '<span style="color: #cecece">(no macro)</span>');
$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 || '');
Expand Down Expand Up @@ -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 = '<span style="color: #cecece">(no reason)</span>';
} else {
Expand Down Expand Up @@ -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) || '<span style="color: #cecece">(no macro)</span>');
$macroContent.find('.edit-area').val(decodeURIComponent(config.modMacros[reasonsNum].text) || '<span style="color: #cecece">(no macro)</span>');
$macroContent.find('input[name=macro-title]').val(config.modMacros[reasonsNum].title || '');
$macroContent.find('input[name=edit-note]').val('');

Expand Down Expand Up @@ -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 = '<span style="color: #cecece">(no macro)</span>';
Expand Down
2 changes: 1 addition & 1 deletion modules/macros.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions modules/modbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ if (unmoderatedOn) {

// Append shortcuts
$.each(shortcuts, function (index, value) {
var shortcut = $('<span>- <a href="' + TBUtils.htmlEncode(unescape(value)) + '">' + TBUtils.htmlEncode(unescape(index)) + '</a> </span>');
var shortcut = $('<span>- <a href="' + TBUtils.htmlEncode(decodeURIComponent(value)) + '">' + TBUtils.htmlEncode(decodeURIComponent(index)) + '</a> </span>');

$(shortcut).appendTo('#tb-toolbarshortcuts');
});
Expand Down Expand Up @@ -344,7 +344,7 @@ if (unmoderatedOn) {
<div class="tb-window-content-toolbox">\
<p>\
Import/export toolbox settings to a wiki page:<br>\
<input type="text" name="settingssub" placeholder="Fill in a private subreddit where you are mod..." value="' + TBUtils.htmlEncode(unescape(settingSub)) + '">\
<input type="text" name="settingssub" placeholder="Fill in a private subreddit where you are mod..." value="' + TBUtils.htmlEncode(decodeURIComponent(settingSub)) + '">\
<input class="tb-settings-import" type="button" value="import">\
<input class="tb-settings-export" type="button" value="export">\
<b> Important:</b> This will reload the page without saving!\
Expand Down Expand Up @@ -414,7 +414,7 @@ if (unmoderatedOn) {

} else {
$.each(shortcuts, function (index, value) {
shortcutinput = '<tr class="tb-window-content-shortcuts-tr"><td><input type="text" value="' + TBUtils.htmlEncode(unescape(index)) + '" name="name"> </td><td> <input type="text" value="' + TBUtils.htmlEncode(unescape(value)) + '" name="url"> <td><td class="tb-window-content-shortcuts-td-remove">\
shortcutinput = '<tr class="tb-window-content-shortcuts-tr"><td><input type="text" value="' + TBUtils.htmlEncode(decodeURIComponent(index)) + '" name="name"> </td><td> <input type="text" value="' + TBUtils.htmlEncode(decodeURIComponent(value)) + '" name="url"> <td><td class="tb-window-content-shortcuts-td-remove">\
<a class="tb-remove-shortcuts" href="javascript:void(0)"><img src="data:image/png;base64,' + TBui.iconDelete + '" /></a></td></tr>\
<br><br>';
//console.log(shortcutinput);
Expand Down Expand Up @@ -460,7 +460,7 @@ See the License for the specific language governing permissions and limitations
$(htmlabout).appendTo('.tb-window-content').hide();
$('<a href="javascript:;" class="tb-window-content-about" data-module="about">About</a>').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) {
Expand Down
6 changes: 3 additions & 3 deletions modules/removalreasons.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion modules/usernotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 5e0f103

Please sign in to comment.