diff --git a/src/octoprint/plugins/appkeys/static/js/appkeys.js b/src/octoprint/plugins/appkeys/static/js/appkeys.js index bdd72e97b..bb5fdc822 100644 --- a/src/octoprint/plugins/appkeys/static/js/appkeys.js +++ b/src/octoprint/plugins/appkeys/static/js/appkeys.js @@ -52,7 +52,7 @@ $(function() { .done(self.requestData); }; - showConfirmationDialog(_.sprintf(gettext("You are about to revoke the application key \"%(key)s\"."), {key: key}), + showConfirmationDialog(_.sprintf(gettext("You are about to revoke the application key \"%(key)s\"."), {key: _.escape(key)}), perform); }; @@ -68,7 +68,7 @@ $(function() { self.promptForAccess = function(app, token) { var message = gettext("\"%(app)s\" has requested access to control OctoPrint through the API."); - message = _.sprintf(message, {app: app}); + message = _.sprintf(message, {app: _.escape(app)}); message = "
" + message + "
" + gettext("Do you want to allow access to this application with your user account?") + "
"; return new PNotify({ title: gettext("Access Request"), @@ -210,7 +210,7 @@ $(function() { .done(self.requestData); }; - showConfirmationDialog(_.sprintf(gettext("You are about to revoke the application key \"%(key)s\"."), {key: key}), + showConfirmationDialog(_.sprintf(gettext("You are about to revoke the application key \"%(key)s\"."), {key: _.escape(key)}), perform); }; @@ -258,11 +258,11 @@ $(function() { handler = function(key) { return OctoPrint.plugins.appkeys.revokeKey(key) .done(function() { - deferred.notify(_.sprintf(gettext("Revoked %(key)s..."), {key: key}), true); + deferred.notify(_.sprintf(gettext("Revoked %(key)s..."), {key: _.escape(key)}), true); }) .fail(function(jqXHR) { - var short = _.sprintf(gettext("Revocation of %(key)s failed, continuing..."), {key: key}); - var long = _.sprintf(gettext("Deletion of %(key)s failed: %(error)s"), {key: key, error: jqXHR.responseText}); + var short = _.sprintf(gettext("Revocation of %(key)s failed, continuing..."), {key: _.escape(key)}); + var long = _.sprintf(gettext("Deletion of %(key)s failed: %(error)s"), {key: _.escape(key), error: _.escape(jqXHR.responseText)}); deferred.notify(short, long, false); }); }; diff --git a/src/octoprint/plugins/backup/static/js/backup.js b/src/octoprint/plugins/backup/static/js/backup.js index 348860204..2414b3a53 100644 --- a/src/octoprint/plugins/backup/static/js/backup.js +++ b/src/octoprint/plugins/backup/static/js/backup.js @@ -85,7 +85,7 @@ $(function() { self.requestData(); }); }; - showConfirmationDialog(_.sprintf(gettext("You are about to delete backup file \"%(name)s\"."), {name: backup}), + showConfirmationDialog(_.sprintf(gettext("You are about to delete backup file \"%(name)s\"."), {name: _.escape(backup)}), perform); }; @@ -101,7 +101,7 @@ $(function() { OctoPrint.plugins.backup.restoreBackup(backup); }; - showConfirmationDialog(_.sprintf(gettext("You are about to restore the backup file \"%(name)s\". This cannot be undone."), {name: backup}), + showConfirmationDialog(_.sprintf(gettext("You are about to restore the backup file \"%(name)s\". This cannot be undone."), {name: _.escape(backup)}), perform); }; @@ -117,7 +117,7 @@ $(function() { self.backupUploadData.submit(); }; - showConfirmationDialog(_.sprintf(gettext("You are about to upload and restore the backup file \"%(name)s\". This cannot be undone."), {name: self.backupUploadName()}), + showConfirmationDialog(_.sprintf(gettext("You are about to upload and restore the backup file \"%(name)s\". This cannot be undone."), {name: _.escape(self.backupUploadName())}), perform); }; @@ -182,7 +182,7 @@ $(function() { self.backupInProgress(false); new PNotify({ title: gettext("Creating the backup failed"), - text: _.sprintf(gettext("OctoPrint could not create your backup. Please consultoctoprint.log for details. Error: %(error)s"), {error:data.error}),
+ text: _.sprintf(gettext("OctoPrint could not create your backup. Please consult octoprint.log for details. Error: %(error)s"), {error: _.escape(data.error)}),
type: "error",
hide: false
});
@@ -200,13 +200,13 @@ $(function() {
} else if (data.type === "installing_plugin") {
self.loglines.push({line: " ", stream: "message"});
self.loglines.push({
- line: _.sprintf(gettext("Installing plugin \"%(plugin)s\"..."), {plugin: data.plugin}),
+ line: _.sprintf(gettext("Installing plugin \"%(plugin)s\"..."), {plugin: _.escape(data.plugin)}),
stream: "message"
});
} else if (data.type === "plugin_incompatible") {
self.loglines.push({line: " ", stream: "message"});
self.loglines.push({
- line: _.sprintf(gettext("Cannot install plugin \"%(plugin)s\" due to it being incompatible to this OctoPrint version and/or underlying operating system"), {plugin: data.plugin.key}),
+ line: _.sprintf(gettext("Cannot install plugin \"%(plugin)s\" due to it being incompatible to this OctoPrint version and/or underlying operating system"), {plugin: _.escape(data.plugin.key)}),
stream: "stderr"
});
} else if (data.type === "unknown_plugins") {
@@ -245,11 +245,11 @@ $(function() {
handler = function(filename) {
return OctoPrint.plugins.backup.deleteBackup(filename)
.done(function() {
- deferred.notify(_.sprintf(gettext("Deleted %(filename)s..."), {filename: filename}), true);
+ deferred.notify(_.sprintf(gettext("Deleted %(filename)s..."), {filename: _.escape(filename)}), true);
})
.fail(function(jqXHR) {
- var short = _.sprintf(gettext("Deletion of %(filename)s failed, continuing..."), {filename: filename});
- var long = _.sprintf(gettext("Deletion of %(filename)s failed: %(error)s"), {filename: filename, error: jqXHR.responseText});
+ var short = _.sprintf(gettext("Deletion of %(filename)s failed, continuing..."), {filename: _.escape(filename)});
+ var long = _.sprintf(gettext("Deletion of %(filename)s failed: %(error)s"), {filename: _.escape(filename), error: _.escape(jqXHR.responseText)});
deferred.notify(short, long, false);
});
};
diff --git a/src/octoprint/plugins/logging/static/js/logging.js b/src/octoprint/plugins/logging/static/js/logging.js
index f465b5fe7..7a7978ac7 100644
--- a/src/octoprint/plugins/logging/static/js/logging.js
+++ b/src/octoprint/plugins/logging/static/js/logging.js
@@ -121,7 +121,7 @@ $(function() {
.done(self.requestData);
};
- showConfirmationDialog(_.sprintf(gettext("You are about to delete log file \"%(name)s\"."), {name: filename}),
+ showConfirmationDialog(_.sprintf(gettext("You are about to delete log file \"%(name)s\"."), {name: _.escape(filename)}),
perform);
};
@@ -172,11 +172,11 @@ $(function() {
var handler = function(filename) {
return OctoPrint.plugins.logging.deleteLog(filename)
.done(function() {
- deferred.notify(_.sprintf(gettext("Deleted %(filename)s..."), {filename: filename}), true);
+ deferred.notify(_.sprintf(gettext("Deleted %(filename)s..."), {filename: _.escape(filename)}), true);
})
.fail(function(jqXHR) {
- var short = _.sprintf(gettext("Deletion of %(filename)s failed, continuing..."), {filename: filename});
- var long = _.sprintf(gettext("Deletion of %(filename)s failed: %(error)s"), {filename: filename, error: jqXHR.responseText});
+ var short = _.sprintf(gettext("Deletion of %(filename)s failed, continuing..."), {filename: _.escape(filename)});
+ var long = _.sprintf(gettext("Deletion of %(filename)s failed: %(error)s"), {filename: _.escape(filename), error: _.escape(jqXHR.responseText)});
deferred.notify(short, long, false);
});
};
diff --git a/src/octoprint/plugins/pluginmanager/static/js/pluginmanager.js b/src/octoprint/plugins/pluginmanager/static/js/pluginmanager.js
index 5c31b5377..859375da3 100644
--- a/src/octoprint/plugins/pluginmanager/static/js/pluginmanager.js
+++ b/src/octoprint/plugins/pluginmanager/static/js/pluginmanager.js
@@ -444,7 +444,7 @@ $(function() {
// always warn if plugin is marked "disabling discouraged"
if (data.disabling_discouraged) {
- var message = _.sprintf(gettext("You are about to disable \"%(name)s\"."), {name: data.name})
+ var message = _.sprintf(gettext("You are about to disable \"%(name)s\"."), {name: _.escape(data.name)})
+ "" + data.disabling_discouraged; showConfirmationDialog({ title: gettext("This is not recommended"), @@ -458,7 +458,7 @@ $(function() { // warn if global "warn disabling" setting is set" else if (self.settingsViewModel.settings.plugins.pluginmanager.confirm_disable()) { showConfirmationDialog({ - message: _.sprintf(gettext("You are about to disable \"%(name)s\""), {name: data.name}), + message: _.sprintf(gettext("You are about to disable \"%(name)s\""), {name: _.escape(data.name)}), cancel: gettext("Keep enabled"), proceed: gettext("Disable plugin"), onproceed: performDisabling, @@ -517,13 +517,13 @@ $(function() { if (!reinstall) { workTitle = gettext("Installing plugin..."); if (name) { - workText = _.sprintf(gettext("Installing plugin \"%(name)s\" from %(url)s..."), {url: url, name: name}); + workText = _.sprintf(gettext("Installing plugin \"%(name)s\" from %(url)s..."), {url: _.escape(url), name: _.escape(name)}); } else { - workText = _.sprintf(gettext("Installing plugin from %(url)s..."), {url: url}); + workText = _.sprintf(gettext("Installing plugin from %(url)s..."), {url: _.escape(url)}); } } else { workTitle = gettext("Reinstalling plugin..."); - workText = _.sprintf(gettext("Reinstalling plugin \"%(name)s\" from %(url)s..."), {url: url, name: name}); + workText = _.sprintf(gettext("Reinstalling plugin \"%(name)s\" from %(url)s..."), {url: _.escape(url), name: _.escape(name)}); } self._markWorking(workTitle, workText); @@ -572,7 +572,7 @@ $(function() { // defining actual uninstall logic as functor in order to handle // the confirm/no-confirm logic without duplication of logic var performUninstall = function() { - self._markWorking(gettext("Uninstalling plugin..."), _.sprintf(gettext("Uninstalling plugin \"%(name)s\""), {name: data.name})); + self._markWorking(gettext("Uninstalling plugin..."), _.sprintf(gettext("Uninstalling plugin \"%(name)s\""), {name: _.escape(data.name)})); OctoPrint.plugins.pluginmanager.uninstall(data.key) .done(function() { @@ -594,7 +594,7 @@ $(function() { if (self.settingsViewModel.settings.plugins.pluginmanager.confirm_uninstall()) { // confirmation needed. Show confirmation dialog and call performUninstall if user clicks Yes showConfirmationDialog({ - message: _.sprintf(gettext("You are about to uninstall the plugin \"%(name)s\""), {name: data.name}), + message: _.sprintf(gettext("You are about to uninstall the plugin \"%(name)s\""), {name: _.escape(data.name)}), cancel: gettext("Keep installed"), proceed: gettext("Uninstall"), onproceed: performUninstall, @@ -756,7 +756,7 @@ $(function() { } text += "
The server is currently running in safe mode. Third party plugins and language packs are disabled and cannot be enabled.
Reason: %(reason)s
"), {reason: reason}), + text: _.sprintf(gettext("The server is currently running in safe mode. Third party plugins and language packs are disabled and cannot be enabled.
Reason: %(reason)s
"), {reason: _.escape(reason)}), hide: false }); } @@ -251,7 +251,7 @@ function DataUpdater(allViewModels, connectCallback, disconnectCallback) { } self._printerErrorCancelNotification = new PNotify({ title: gettext("Error reported by printer"), - text: _.sprintf(gettext("Your printer's firmware reported an error. Due to that the ongoing print job will be cancelled. Reported error: %(firmwareError)s"), payload), + text: _.sprintf(gettext("Your printer's firmware reported an error. Due to that the ongoing print job will be cancelled. Reported error: %(firmwareError)s"), _.escape(payload)), type: "error", hide: false }); @@ -262,24 +262,24 @@ function DataUpdater(allViewModels, connectCallback, disconnectCallback) { switch (payload.reason) { case "firmware": { title = gettext("Error reported by printer"); - text = _.sprintf(gettext("Your printer's firmware reported an error. Due to that OctoPrint will disconnect. Reported error: %(error)s"), payload); + text = _.sprintf(gettext("Your printer's firmware reported an error. Due to that OctoPrint will disconnect. Reported error: %(error)s"), _.escape(payload)); break; } case "resend": case "resend_loop": case "timeout": { title = gettext("Communication error"); - text = _.sprintf(gettext("There was a communication error while talking to your printer. Please consult the terminal output and octoprint.log for details. Error: %(error)s"), payload); + text = _.sprintf(gettext("There was a communication error while talking to your printer. Please consult the terminal output and octoprint.log for details. Error: %(error)s"), _.escape(payload)); break; } case "connection": { title = gettext("Error connecting to printer"); - text = _.sprintf(gettext("There was an error while trying to connect to your printer. Error: %(error)s"), payload); + text = _.sprintf(gettext("There was an error while trying to connect to your printer. Error: %(error)s"), _.escape(payload)); break; } case "start_print": { title = gettext("Error starting a print"); - text = _.sprintf(gettext("There was an error while trying to start a print job. Error: %(error)s"), payload); + text = _.sprintf(gettext("There was an error while trying to start a print job. Error: %(error)s"), _.escape(payload)); break; } case "autodetect_port": @@ -289,7 +289,7 @@ function DataUpdater(allViewModels, connectCallback, disconnectCallback) { } default: { title = gettext("Unknown error"); - text = _.sprintf(gettext("There was an unknown error while talking to your printer. Please consult the terminal output and octoprint.log for details. Error: %(error)s"), payload); + text = _.sprintf(gettext("There was an unknown error while talking to your printer. Please consult the terminal output and octoprint.log for details. Error: %(error)s"), _.escape(payload)); break; } } diff --git a/src/octoprint/static/js/app/viewmodels/files.js b/src/octoprint/static/js/app/viewmodels/files.js index 1790ef2ec..b420a8554 100644 --- a/src/octoprint/static/js/app/viewmodels/files.js +++ b/src/octoprint/static/js/app/viewmodels/files.js @@ -150,7 +150,7 @@ $(function() { if (mapping[filetype]) { result.push({key: filetype, text: mapping[filetype]}); } else { - result.push({key: filetype, text: _.sprintf(gettext("Only show %(type)s files"), {type: filetype})}); + result.push({key: filetype, text: _.sprintf(gettext("Only show %(type)s files"), {type: _.escape(filetype)})}); } }); @@ -436,7 +436,7 @@ $(function() { if (folder.weight > 0) { // confirm recursive delete var options = { - message: _.sprintf(gettext("You are about to delete the folder \"%(folder)s\" which still contains files and/or sub folders."), {folder: folder.name}), + message: _.sprintf(gettext("You are about to delete the folder \"%(folder)s\" which still contains files and/or sub folders."), {folder: _.escape(folder.name)}), onproceed: function() { self._removeEntry(folder, event); } @@ -727,7 +727,7 @@ $(function() { } // model not within bounds, we need to prepare a warning - var warning = "" + _.sprintf(gettext("Object in %(name)s exceeds the print volume of the currently selected printer profile, be careful when printing this."), data) + "
"; + var warning = "" + _.sprintf(gettext("Object in %(name)s exceeds the print volume of the currently selected printer profile, be careful when printing this."), {name: _.escape(data.name)}) + "
"; var info = ""; var formatData = { @@ -957,7 +957,7 @@ $(function() { new PNotify({ title: gettext("Slicing done"), - text: _.sprintf(gettext("Sliced %(stl)s to %(gcode)s, took %(time).2f seconds"), payload), + text: _.sprintf(gettext("Sliced %(stl)s to %(gcode)s, took %(time).2f seconds"), {stl: _.escape(payload.stl), gcode: _.escape(payload.gcode), time: payload.time}), type: "success" }); @@ -972,7 +972,7 @@ $(function() { .css("width", "0%"); self.uploadProgressText(""); - var html = _.sprintf(gettext("Could not slice %(stl)s to %(gcode)s: %(reason)s"), payload); + var html = _.sprintf(gettext("Could not slice %(stl)s to %(gcode)s: %(reason)s"), {stl: _.escape(payload.stl), gcode: _.escape(payload.gcode), reason: _.escape(payload.reason)}); new PNotify({title: gettext("Slicing failed"), text: html, type: "error", hide: false}); }; @@ -1003,7 +1003,7 @@ $(function() { new PNotify({ title: gettext("Streaming done"), - text: _.sprintf(gettext("Streamed %(local)s to %(remote)s on SD, took %(time).2f seconds"), payload), + text: _.sprintf(gettext("Streamed %(local)s to %(remote)s on SD, took %(time).2f seconds"), {local: _.escape(payload.local), remote: _.escape(payload.remote), time: payload.time}), type: "success" }); @@ -1020,7 +1020,7 @@ $(function() { new PNotify({ title: gettext("Streaming failed"), - text: _.sprintf(gettext("Did not finish streaming %(local)s to %(remote)s on SD"), payload), + text: _.sprintf(gettext("Did not finish streaming %(local)s to %(remote)s on SD"), {local: _.escape(payload.local), remote: _.escape(payload.remote)}), type: "error" }); @@ -1121,10 +1121,10 @@ $(function() { extensions = extensions.join(", "); var error = "" + _.sprintf(gettext("Could not upload the file. Make sure that it is a readable, valid file with one of these extensions: %(extensions)s"), - {extensions: extensions}) + {extensions: _.escape(extensions)}) + "
"; if (data.jqXHR.responseText) { - error += pnotifyAdditionalInfo("" + data.jqXHR.responseText + ""); + error += pnotifyAdditionalInfo("
" + _.escape(data.jqXHR.responseText) + ""); } new PNotify({ title: "Upload failed", diff --git a/src/octoprint/static/js/app/viewmodels/loginstate.js b/src/octoprint/static/js/app/viewmodels/loginstate.js index d00e7f804..3b90694a3 100644 --- a/src/octoprint/static/js/app/viewmodels/loginstate.js +++ b/src/octoprint/static/js/app/viewmodels/loginstate.js @@ -32,7 +32,7 @@ $(function() { self.userMenuTitle = ko.pureComputed(function() { if (self.loggedIn()) { - return _.sprintf(gettext("Logged in as %(name)s"), {name: self.username()}); + return _.sprintf(gettext("Logged in as %(name)s"), {name: _.escape(self.username())}); } else { return gettext("Login"); } @@ -160,7 +160,7 @@ $(function() { return OctoPrint.browser.login(username, password, remember) .done(function(response) { - new PNotify({title: gettext("Login successful"), text: _.sprintf(gettext('You are now logged in as "%(username)s"'), {username: response.name}), type: "success"}); + new PNotify({title: gettext("Login successful"), text: _.sprintf(gettext('You are now logged in as "%(username)s"'), {username: _.escape(response.name)}), type: "success"}); self.fromResponse(response); self.loginUser(""); diff --git a/src/octoprint/static/js/app/viewmodels/printerprofiles.js b/src/octoprint/static/js/app/viewmodels/printerprofiles.js index 556063848..0c7ed135e 100644 --- a/src/octoprint/static/js/app/viewmodels/printerprofiles.js +++ b/src/octoprint/static/js/app/viewmodels/printerprofiles.js @@ -533,7 +533,7 @@ $(function() { }); }; - showConfirmationDialog(_.sprintf(gettext("You are about to delete the printer profile \"%(name)s\"."), {name: data.name}), + showConfirmationDialog(_.sprintf(gettext("You are about to delete the printer profile \"%(name)s\"."), {name: _.escape(data.name)}), perform); }; @@ -568,7 +568,7 @@ $(function() { var dialogTitle = $("h3.modal-title", editDialog); var add = data === undefined; - dialogTitle.text(add ? gettext("Add Printer Profile") : _.sprintf(gettext("Edit Printer Profile \"%(name)s\""), {name: data.name})); + dialogTitle.text(add ? gettext("Add Printer Profile") : _.sprintf(gettext("Edit Printer Profile \"%(name)s\""), {name: _.escape(data.name)})); confirmButton.unbind("click"); confirmButton.bind("click", function() { if (self.enableEditorSubmitButton()) { diff --git a/src/octoprint/static/js/app/viewmodels/settings.js b/src/octoprint/static/js/app/viewmodels/settings.js index a51b6689f..c90fa42c3 100644 --- a/src/octoprint/static/js/app/viewmodels/settings.js +++ b/src/octoprint/static/js/app/viewmodels/settings.js @@ -375,7 +375,7 @@ $(function() { "image. Got this as a content type header:
%(content_type)s. Please " +
"double check that the URL is returning static images, not multipart data " +
"or videos.");
- errorText = _.sprintf(errorText, {content_type: response.response.content_type});
+ errorText = _.sprintf(errorText, {content_type: _.escape(response.response.content_type)});
}
showMessageDialog({
diff --git a/src/octoprint/static/js/app/viewmodels/slicing.js b/src/octoprint/static/js/app/viewmodels/slicing.js
index 169453109..71784813e 100644
--- a/src/octoprint/static/js/app/viewmodels/slicing.js
+++ b/src/octoprint/static/js/app/viewmodels/slicing.js
@@ -146,7 +146,7 @@ $(function() {
self.target = target;
self.file(file);
self.path = path;
- self.title(_.sprintf(gettext("Slicing %(filename)s"), {filename: display}));
+ self.title(_.sprintf(gettext("Slicing %(filename)s"), {filename: _.escape(display)}));
self.destinationFilename(destination);
self.printerProfile(self.printerProfiles.currentProfile());
self.afterSlicing("none");
diff --git a/src/octoprint/static/js/app/viewmodels/system.js b/src/octoprint/static/js/app/viewmodels/system.js
index af1dbb87c..ade7c0eb5 100644
--- a/src/octoprint/static/js/app/viewmodels/system.js
+++ b/src/octoprint/static/js/app/viewmodels/system.js
@@ -56,15 +56,15 @@ $(function() {
new PNotify({
title: "Success",
- text: _.sprintf(text, {command: commandSpec.name}),
+ text: _.sprintf(text, {command: _.escape(commandSpec.name)}),
type: "success"
});
deferred.resolve(["success", arguments]);
})
.fail(function(jqXHR, textStatus, errorThrown) {
if (!commandSpec.hasOwnProperty("ignore") || !commandSpec.ignore) {
- var error = "" + _.sprintf(gettext("The command \"%(command)s\" could not be executed."), {command: commandSpec.name}) + "
"; - error += pnotifyAdditionalInfo("" + jqXHR.responseText + ""); + var error = "
" + _.sprintf(gettext("The command \"%(command)s\" could not be executed."), {command: _.escape(commandSpec.name)}) + "
"; + error += pnotifyAdditionalInfo("" + _.escape(jqXHR.responseText) + ""); new PNotify({title: gettext("Error"), text: error, type: "error", hide: false}); deferred.reject(["error", arguments]); } else { diff --git a/src/octoprint/static/js/app/viewmodels/temperature.js b/src/octoprint/static/js/app/viewmodels/temperature.js index caa9e31fc..50f6d5513 100644 --- a/src/octoprint/static/js/app/viewmodels/temperature.js +++ b/src/octoprint/static/js/app/viewmodels/temperature.js @@ -58,11 +58,11 @@ $(function() { item: undefined, title: ko.pureComputed(function() { - return _.sprintf(gettext("Changing Offset of %(name)s"), {name: self.changingOffset.name()}); + return _.sprintf(gettext("Changing Offset of %(name)s"), {name: _.escape(self.changingOffset.name())}); }), description: ko.pureComputed(function() { return _.sprintf(gettext("Use the form below to specify a new offset to apply to all temperature commands sent from printed files for \"%(name)s\""), - {name: self.changingOffset.name()}); + {name: _.escape(self.changingOffset.name())}); }) }; self.changeOffsetDialog = undefined; @@ -348,7 +348,7 @@ $(function() { value = "" + value + "°C"; } - return _.sprintf(text, {name: profile.name, value: value}); + return _.sprintf(text, {name: _.escape(profile.name), value: _.escape(value)}); }; self.updatePlot = function() { diff --git a/src/octoprint/static/js/app/viewmodels/timelapse.js b/src/octoprint/static/js/app/viewmodels/timelapse.js index 958fa2786..bb50cc1e7 100644 --- a/src/octoprint/static/js/app/viewmodels/timelapse.js +++ b/src/octoprint/static/js/app/viewmodels/timelapse.js @@ -238,8 +238,8 @@ $(function() { self.requestData() }) .fail(function(jqXHR) { - var html = "
" + _.sprintf(gettext("Failed to remove timelapse %(name)s.
Please consult octoprint.log for details.
"), {name: filename}); - html += pnotifyAdditionalInfo('' + jqXHR.responseText + ''); + var html = "
" + _.sprintf(gettext("Failed to remove timelapse %(name)s.
Please consult octoprint.log for details.
"), {name: _.escape(filename)}); + html += pnotifyAdditionalInfo('' + _.escape(jqXHR.responseText) + ''); new PNotify({ title: gettext("Could not remove timelapse"), text: html, @@ -249,7 +249,7 @@ $(function() { }); }; - showConfirmationDialog(_.sprintf(gettext("You are about to delete timelapse file \"%(name)s\"."), {name: filename}), + showConfirmationDialog(_.sprintf(gettext("You are about to delete timelapse file \"%(name)s\"."), {name: _.escape(filename)}), perform) }; @@ -286,7 +286,7 @@ $(function() { }); }; - showConfirmationDialog(_.sprintf(gettext("You are about to delete unrendered timelapse \"%(name)s\"."), {name: name}), + showConfirmationDialog(_.sprintf(gettext("You are about to delete unrendered timelapse \"%(name)s\"."), {name: _.escape(name)}), perform) }; @@ -311,11 +311,11 @@ $(function() { handler = function(filename) { return OctoPrint.timelapse.delete(filename) .done(function() { - deferred.notify(_.sprintf(gettext("Deleted %(filename)s..."), {filename: filename}), true); + deferred.notify(_.sprintf(gettext("Deleted %(filename)s..."), {filename: _.escape(filename)}), true); }) .fail(function(jqXHR) { - var short = _.sprintf(gettext("Deletion of %(filename)s failed, continuing..."), {filename: filename}); - var long = _.sprintf(gettext("Deletion of %(filename)s failed: %(error)s"), {filename: filename, error: jqXHR.responseText}); + var short = _.sprintf(gettext("Deletion of %(filename)s failed, continuing..."), {filename: _.escape(filename)}); + var long = _.sprintf(gettext("Deletion of %(filename)s failed: %(error)s"), {filename: _.escape(filename), error: _.escape(jqXHR.responseText)}); deferred.notify(short, long, false); }); } @@ -325,10 +325,10 @@ $(function() { handler = function(filename) { return OctoPrint.timelapse.deleteUnrendered(filename) .done(function() { - deferred.notify(_.sprintf(gettext("Deleted %(filename)s..."), {filename: filename}), true); + deferred.notify(_.sprintf(gettext("Deleted %(filename)s..."), {filename: _.escape(filename)}), true); }) .fail(function() { - deferred.notify(_.sprintf(gettext("Deletion of %(filename)s failed, continuing..."), {filename: filename}), false); + deferred.notify(_.sprintf(gettext("Deletion of %(filename)s failed, continuing..."), {filename: _.escape(filename)}), false); }); } } else { @@ -419,7 +419,7 @@ $(function() { var text; if (!payload.postroll_duration) { - text = _.sprintf(gettext("Now capturing timelapse post roll, this will take only a moment..."), format); + text = _.sprintf(gettext("Now capturing timelapse post roll, this will take only a moment...")); } else { var format = { time: moment().add(payload.postroll_duration, "s").format("LT") @@ -473,7 +473,7 @@ $(function() { self.onEventMovieRendering = function(payload) { self.displayTimelapsePopup({ title: gettext("Rendering timelapse"), - text: _.sprintf(gettext("Now rendering timelapse %(movie_prefix)s. Due to performance reasons it is not recommended to start a print job while a movie is still rendering."), payload), + text: _.sprintf(gettext("Now rendering timelapse %(movie_prefix)s. Due to performance reasons it is not recommended to start a print job while a movie is still rendering."), {movie_prefix: _.escape(payload.movie_prefix)}), hide: false }); }; @@ -483,14 +483,14 @@ $(function() { if (payload.reason === "no_frames") { title = gettext("Cannot render timelapse"); - html = "
" + _.sprintf(gettext("Rendering of timelapse %(movie_prefix)s is not possible since no frames were captured. Is the snapshot URL configured correctly?"), payload) + "
"; + html = "" + _.sprintf(gettext("Rendering of timelapse %(movie_prefix)s is not possible since no frames were captured. Is the snapshot URL configured correctly?"), {movie_prefix: _.escape(payload.movie_prefix)}) + "
"; } else if (payload.reason = "returncode") { title = gettext("Rendering timelapse failed"); - html = "" + _.sprintf(gettext("Rendering of timelapse %(movie_prefix)s failed with return code %(returncode)s"), payload) + "
"; + html = "" + _.sprintf(gettext("Rendering of timelapse %(movie_prefix)s failed with return code %(returncode)s"), {movie_prefix: _.escape(payload.movie_prefix), returncode: _.escape(payload.returncode)}) + "
"; html += pnotifyAdditionalInfo('' + payload.error + ''); } else { title = gettext("Rendering timelapse failed"); - html = "
" + _.sprintf(gettext("Rendering of timelapse %(movie_prefix)s failed due to an unknown error, please consult the log file"), payload) + "
"; + html = "" + _.sprintf(gettext("Rendering of timelapse %(movie_prefix)s failed due to an unknown error, please consult the log file"), {movie_prefix: _.escape(payload.movie_prefix)}) + "
"; } self.displayTimelapsePopup({ @@ -504,7 +504,7 @@ $(function() { self.onEventMovieDone = function(payload) { self.displayTimelapsePopup({ title: gettext("Timelapse ready"), - text: _.sprintf(gettext("New timelapse %(movie_prefix)s is done rendering."), payload), + text: _.sprintf(gettext("New timelapse %(movie_prefix)s is done rendering."), {movie_prefix: _.escape(payload.movie_prefix)}), type: "success", callbacks: { before_close: function(notice) {