Browse Source

WebUI: Avoid decoding strings repeatedly

Fix #14553
adaptive-webui-19844
brvphoenix 4 years ago
parent
commit
5beb1b2cd0
  1. 2
      src/webui/www/private/confirmfeeddeletion.html
  2. 2
      src/webui/www/private/confirmruleclear.html
  3. 2
      src/webui/www/private/confirmruledeletion.html
  4. 5
      src/webui/www/private/edittracker.html
  5. 2
      src/webui/www/private/rename.html
  6. 3
      src/webui/www/private/rename_file.html
  7. 4
      src/webui/www/private/scripts/mocha-init.js
  8. 2
      src/webui/www/private/setlocation.html
  9. 3
      src/webui/www/private/views/rss.html
  10. 6
      src/webui/www/private/views/rssDownloader.html

2
src/webui/www/private/confirmfeeddeletion.html

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

2
src/webui/www/private/confirmruleclear.html

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

2
src/webui/www/private/confirmruledeletion.html

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

5
src/webui/www/private/edittracker.html

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

2
src/webui/www/private/rename.html

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

3
src/webui/www/private/rename_file.html

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

4
src/webui/www/private/scripts/mocha-init.js

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

2
src/webui/www/private/setlocation.html

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

3
src/webui/www/private/views/rss.html

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

6
src/webui/www/private/views/rssDownloader.html

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

Loading…
Cancel
Save