WebUI: Avoid decoding strings repeatedly

Fix #14553
This commit is contained in:
brvphoenix 2021-03-19 01:27:36 -07:00
parent f6ab1d63e8
commit 5beb1b2cd0
10 changed files with 16 additions and 15 deletions

View File

@ -26,7 +26,7 @@
noCache: true,
method: 'post',
data: {
path: path
path: decodeURIComponent(path)
},
onComplete: (response) => {
++completionCount;

View File

@ -22,7 +22,7 @@
new Event(e).stop();
let completionCount = 0;
rules.forEach((rule) => {
window.parent.qBittorrent.RssDownloader.modifyRuleState(rule, 'previouslyMatchedEpisodes', [], () => {
window.parent.qBittorrent.RssDownloader.modifyRuleState(decodeURIComponent(rule), 'previouslyMatchedEpisodes', [], () => {
++completionCount;
if (completionCount === rules.length) {
window.parent.qBittorrent.RssDownloader.updateRulesList();

View File

@ -27,7 +27,7 @@
noCache: true,
method: 'post',
data: {
ruleName: rule
ruleName: decodeURIComponent(rule)
},
onComplete: (response) => {
++completionCount;

View File

@ -33,8 +33,7 @@
if (!currentUrl)
return false;
const decodedUrl = decodeURIComponent(currentUrl);
$('trackerUrl').value = decodedUrl;
$('trackerUrl').value = currentUrl;
$('trackerUrl').focus();
$('editTrackerButton').addEvent('click', function(e) {
@ -45,7 +44,7 @@
method: 'post',
data: {
hash: hash,
origUrl: decodedUrl,
origUrl: currentUrl,
newUrl: $('trackerUrl').value
},
onComplete: function() {

View File

@ -33,7 +33,7 @@
const name = new URI().getData('name');
// set text field to current value
if (name)
$('rename').value = decodeURIComponent(name);
$('rename').value = name;
$('rename').focus();
$('renameButton').addEvent('click', function(e) {

View File

@ -32,10 +32,9 @@
window.addEvent('domready', function() {
const hash = new URI().getData('hash');
const path = new URI().getData('path');
const oldPath = new URI().getData('path');
const isFolder = ((new URI().getData('isFolder')) === 'true');
const oldPath = decodeURIComponent(path);
const oldName = window.qBittorrent.Filesystem.fileName(oldPath);
$('rename').value = oldName;
$('rename').focus();

View File

@ -120,9 +120,9 @@ const initializeWindows = function() {
const id = 'downloadPage';
let contentUrl = 'download.html';
if (urls && (urls.length > 0)) {
contentUrl += ('?urls=' + urls.map(function(url) {
contentUrl += ('?urls=' + encodeURIComponent(urls.map(function(url) {
return encodeURIComponent(url);
}).join("|"));
}).join("|")));
}
new MochaUI.Window({

View File

@ -33,7 +33,7 @@
const path = new URI().getData('path');
// set text field to current value
if (path)
$('setLocation').value = window.qBittorrent.Misc.escapeHtml(decodeURIComponent(path));
$('setLocation').value = window.qBittorrent.Misc.escapeHtml(path);
$('setLocation').focus();
$('setLocationButton').addEvent('click', function(e) {

View File

@ -697,11 +697,12 @@
};
const removeItem = (paths) => {
const encodedPaths = paths.map((path) => encodeURIComponent(path));
new MochaUI.Window({
id: 'confirmFeedDeletionPage',
title: 'QBT_TR(Deletion confirmation)QBT_TR[CONTEXT=RSSWidget]',
loadMethod: 'iframe',
contentURL: 'confirmfeeddeletion.html?paths=' + encodeURIComponent(paths.join('|')),
contentURL: 'confirmfeeddeletion.html?paths=' + encodeURIComponent(encodedPaths.join('|')),
scrollbars: false,
resizable: false,
maximizable: false,

View File

@ -535,11 +535,12 @@ Supports the formats: S01E01, 1x1, 2017.12.31 and 31.12.2017 (Date formats also
};
const removeRules = (rules) => {
const encodedRules = rules.map((rule) => encodeURIComponent(rule));
new MochaUI.Window({
id: 'removeRulePage',
title: 'QBT_TR(Rule deletion confirmation)QBT_TR[CONTEXT=AutomatedRssDownloader]',
loadMethod: 'iframe',
contentURL: 'confirmruledeletion.html?rules=' + encodeURIComponent(rules.join('|')),
contentURL: 'confirmruledeletion.html?rules=' + encodeURIComponent(encodedRules.join('|')),
scrollbars: false,
resizable: false,
maximizable: false,
@ -549,11 +550,12 @@ Supports the formats: S01E01, 1x1, 2017.12.31 and 31.12.2017 (Date formats also
};
const clearDownloadedEpisodes = (rules) => {
const encodedRules = rules.map((rule) => encodeURIComponent(rule));
new MochaUI.Window({
id: 'clearRulesPage',
title: 'QBT_TR(New rule name)QBT_TR[CONTEXT=AutomatedRssDownloader]',
loadMethod: 'iframe',
contentURL: 'confirmruleclear.html?rules=' + encodeURIComponent(rules.join('|')),
contentURL: 'confirmruleclear.html?rules=' + encodeURIComponent(encodedRules.join('|')),
scrollbars: false,
resizable: false,
maximizable: false,