From 2e6ee5716210488eb20f7c9d8387ab2180e07cb6 Mon Sep 17 00:00:00 2001 From: Florian Heilmann Date: Wed, 25 Sep 2019 22:09:20 +0200 Subject: [PATCH 1/8] ActionPrompts: More flexibility for selection_command Allow users to control how and where the choice is inserted into the response by explicitly including "{choice}" in the selection_command --- src/octoprint/plugins/action_command_prompt/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/octoprint/plugins/action_command_prompt/__init__.py b/src/octoprint/plugins/action_command_prompt/__init__.py index dc5f796e8..bfebac31e 100644 --- a/src/octoprint/plugins/action_command_prompt/__init__.py +++ b/src/octoprint/plugins/action_command_prompt/__init__.py @@ -207,7 +207,10 @@ class ActionCommandPromptPlugin(octoprint.plugin.AssetPlugin, return self._close_prompt() - self._printer.commands(["{command} S{choice}".format(command=self._command, + if "{choice}" in self._command: + self._printer.commands([self._command.format(choice=choice)]) + else: + self._printer.commands(["{command} S{choice}".format(command=self._command, choice=choice)]) From 852a2cf157f4632ccb598f4f4bdd7fad9e00b2c9 Mon Sep 17 00:00:00 2001 From: Florian Heilmann Date: Wed, 25 Sep 2019 22:11:11 +0200 Subject: [PATCH 2/8] Fix indentation --- src/octoprint/plugins/action_command_prompt/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/octoprint/plugins/action_command_prompt/__init__.py b/src/octoprint/plugins/action_command_prompt/__init__.py index bfebac31e..ca45ab689 100644 --- a/src/octoprint/plugins/action_command_prompt/__init__.py +++ b/src/octoprint/plugins/action_command_prompt/__init__.py @@ -211,7 +211,7 @@ class ActionCommandPromptPlugin(octoprint.plugin.AssetPlugin, self._printer.commands([self._command.format(choice=choice)]) else: self._printer.commands(["{command} S{choice}".format(command=self._command, - choice=choice)]) + choice=choice)]) __plugin_name__ = "Action Command Prompt Support" From 55980a1c2c2bbf2d9757718a07c2a491f7c856d9 Mon Sep 17 00:00:00 2001 From: Florian Heilmann Date: Wed, 25 Sep 2019 22:12:51 +0200 Subject: [PATCH 3/8] Update AUTHORS.md --- AUTHORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.md b/AUTHORS.md index 38730e8d6..7c5951d33 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -108,6 +108,7 @@ date of first contribution): * [Piotr Usewicz](https://github.com/pusewicz) * [Aliaksei Pilko](https://github.com/aliaksei135) * [Ben Yarmis](https://github.com/byarmis) + * [Florian Heilmann](https://github.com/FHeilmann) OctoPrint started off as a fork of [Cura](https://github.com/daid/Cura) by [Daid Braam](https://github.com/daid). Parts of its communication layer and From 073060d253de571e2faa7dc3417a25420184ff8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Thu, 26 Sep 2019 20:26:47 +0200 Subject: [PATCH 4/8] =?UTF-8?q?=E2=9C=A8=20PMGR:=20Search=20box?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implements #3288 --- .../static/css/pluginmanager.css | 2 +- .../pluginmanager/static/js/pluginmanager.js | 19 ++++++++++++++++++- .../static/less/pluginmanager.less | 7 +++++++ .../templates/pluginmanager_settings.jinja2 | 4 ++++ 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/octoprint/plugins/pluginmanager/static/css/pluginmanager.css b/src/octoprint/plugins/pluginmanager/static/css/pluginmanager.css index 3a37ccc85..24adf0b6e 100644 --- a/src/octoprint/plugins/pluginmanager/static/css/pluginmanager.css +++ b/src/octoprint/plugins/pluginmanager/static/css/pluginmanager.css @@ -1 +1 @@ -#settings_plugin_pluginmanager_pluginlist{display:block;width:auto;height:400px;overflow-x:hidden;overflow-y:scroll;padding-right:2px;margin-bottom:1em}#settings_plugin_pluginmanager_pluginlist table td.settings_plugin_plugin_manager_plugins_name,#settings_plugin_pluginmanager_pluginlist table th.settings_plugin_plugin_manager_plugins_name{text-overflow:ellipsis;text-align:left}#settings_plugin_pluginmanager_pluginlist table td.settings_plugin_plugin_manager_plugins_actions,#settings_plugin_pluginmanager_pluginlist table th.settings_plugin_plugin_manager_plugins_actions{text-align:center;width:80px}#settings_plugin_pluginmanager_pluginlist table td.settings_plugin_plugin_manager_plugins_actions a,#settings_plugin_pluginmanager_pluginlist table th.settings_plugin_plugin_manager_plugins_actions a{text-decoration:none;color:#000}#settings_plugin_pluginmanager_pluginlist table td.settings_plugin_plugin_manager_plugins_actions a.disabled,#settings_plugin_pluginmanager_pluginlist table th.settings_plugin_plugin_manager_plugins_actions a.disabled{color:#ccc;cursor:default}#settings_plugin_pluginmanager_repositorydialog h4{position:relative}#settings_plugin_pluginmanager_repositorydialog h4 a.dropdown-toggle{color:inherit;text-decoration:none;font-size:14px}#settings_plugin_pluginmanager_repositorydialog h4 ul.dropdown-menu{font-size:14px}#settings_plugin_pluginmanager_repositorydialog .form-search{text-align:center;margin-bottom:5px!important}#settings_plugin_pluginmanager_repositorydialog .form-inline{padding:5px 10px 5px 5px;margin-bottom:0}#settings_plugin_pluginmanager_repositorydialog .form-inline .help-block{margin-bottom:0;font-size:85%}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_unavailable{overflow:hidden;width:100%;height:300px;background-image:url(../img/repo_unavailable.png);text-align:center;display:table}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_unavailable div{display:table-cell;vertical-align:middle}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_list{width:auto;height:300px;overflow-x:hidden;overflow-y:scroll;padding-right:2px}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_list .entry{border-bottom:1px solid #ddd;padding:5px}#settings_plugin_pluginmanager_workingdialog_output .message{font-weight:700}#settings_plugin_pluginmanager_workingdialog_output .error{font-weight:700;color:#900}#settings_plugin_pluginmanager_workingdialog_output .stdout{color:#333}#settings_plugin_pluginmanager_workingdialog_output .stderr{color:#900}#settings_plugin_pluginmanager_workingdialog_output .call{color:#009} \ No newline at end of file +#settings_plugin_pluginmanager .form-search{text-align:center;margin-bottom:5px!important}#settings_plugin_pluginmanager_pluginlist{display:block;width:auto;height:400px;overflow-x:hidden;overflow-y:scroll;padding-right:2px;margin-bottom:1em}#settings_plugin_pluginmanager_pluginlist table th.settings_plugin_plugin_manager_plugins_name,#settings_plugin_pluginmanager_pluginlist table td.settings_plugin_plugin_manager_plugins_name{text-overflow:ellipsis;text-align:left}#settings_plugin_pluginmanager_pluginlist table th.settings_plugin_plugin_manager_plugins_actions,#settings_plugin_pluginmanager_pluginlist table td.settings_plugin_plugin_manager_plugins_actions{text-align:center;width:80px}#settings_plugin_pluginmanager_pluginlist table th.settings_plugin_plugin_manager_plugins_actions a,#settings_plugin_pluginmanager_pluginlist table td.settings_plugin_plugin_manager_plugins_actions a{text-decoration:none;color:#000}#settings_plugin_pluginmanager_pluginlist table th.settings_plugin_plugin_manager_plugins_actions a.disabled,#settings_plugin_pluginmanager_pluginlist table td.settings_plugin_plugin_manager_plugins_actions a.disabled{color:#ccc;cursor:default}#settings_plugin_pluginmanager_repositorydialog h4{position:relative}#settings_plugin_pluginmanager_repositorydialog h4 a.dropdown-toggle{color:inherit;text-decoration:none;font-size:14px}#settings_plugin_pluginmanager_repositorydialog h4 ul.dropdown-menu{font-size:14px}#settings_plugin_pluginmanager_repositorydialog .form-search{text-align:center;margin-bottom:5px!important}#settings_plugin_pluginmanager_repositorydialog .form-inline{padding:5px;padding-right:10px;margin-bottom:0}#settings_plugin_pluginmanager_repositorydialog .form-inline .help-block{margin-bottom:0;font-size:85%}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_unavailable{overflow:hidden;width:100%;height:300px;background-image:url(../img/repo_unavailable.png);text-align:center;display:table}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_unavailable div{display:table-cell;vertical-align:middle}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_list{width:auto;height:300px;overflow-x:hidden;overflow-y:scroll;padding-right:2px}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_list .entry{border-bottom:1px solid #ddd;padding:5px}#settings_plugin_pluginmanager_workingdialog_output .message{font-weight:700}#settings_plugin_pluginmanager_workingdialog_output .error{font-weight:700;color:#900}#settings_plugin_pluginmanager_workingdialog_output .stdout{color:#333}#settings_plugin_pluginmanager_workingdialog_output .stderr{color:#900}#settings_plugin_pluginmanager_workingdialog_output .call{color:#009} \ No newline at end of file diff --git a/src/octoprint/plugins/pluginmanager/static/js/pluginmanager.js b/src/octoprint/plugins/pluginmanager/static/js/pluginmanager.js index 9cd15c116..5c31b5377 100644 --- a/src/octoprint/plugins/pluginmanager/static/js/pluginmanager.js +++ b/src/octoprint/plugins/pluginmanager/static/js/pluginmanager.js @@ -93,6 +93,11 @@ $(function() { self.performRepositorySearch(); }); + self.listingSearchQuery = ko.observable(); + self.listingSearchQuery.subscribe(function() { + self.performListingSearch(); + }); + self.installUrl = ko.observable(); self.uploadFilename = ko.observable(); @@ -291,9 +296,21 @@ $(function() { } }); + self.performListingSearch = function() { + var query = self.listingSearchQuery(); + if (query !== undefined && query.trim() !== "") { + query = query.toLocaleLowerCase(); + self.plugins.changeSearchFunction(function (entry) { + return entry && (entry["name"].toLocaleLowerCase().indexOf(query) > -1 || (entry.description && entry.description.toLocaleLowerCase().indexOf(query) > -1)); + }); + } else { + self.plugins.resetSearch(); + } + } + self.performRepositorySearch = function() { var query = self.repositorySearchQuery(); - if (query !== undefined && query.trim() != "") { + if (query !== undefined && query.trim() !== "") { query = query.toLocaleLowerCase(); self.repositoryplugins.changeSearchFunction(function(entry) { return entry && (entry["title"].toLocaleLowerCase().indexOf(query) > -1 || entry["description"].toLocaleLowerCase().indexOf(query) > -1); diff --git a/src/octoprint/plugins/pluginmanager/static/less/pluginmanager.less b/src/octoprint/plugins/pluginmanager/static/less/pluginmanager.less index 2f5832fde..e7f8e10c2 100644 --- a/src/octoprint/plugins/pluginmanager/static/less/pluginmanager.less +++ b/src/octoprint/plugins/pluginmanager/static/less/pluginmanager.less @@ -1,3 +1,10 @@ +#settings_plugin_pluginmanager { + .form-search { + text-align: center; + margin-bottom: 5px !important; + } +} + #settings_plugin_pluginmanager_pluginlist { display: block; width: auto; diff --git a/src/octoprint/plugins/pluginmanager/templates/pluginmanager_settings.jinja2 b/src/octoprint/plugins/pluginmanager/templates/pluginmanager_settings.jinja2 index 02331ec4f..821cf470d 100644 --- a/src/octoprint/plugins/pluginmanager/templates/pluginmanager_settings.jinja2 +++ b/src/octoprint/plugins/pluginmanager/templates/pluginmanager_settings.jinja2 @@ -50,6 +50,10 @@

{{ _('Installed Plugins') }}

+ +
From 0525c9ab40c311d3e0db100f1d37d806647fb46a Mon Sep 17 00:00:00 2001 From: Mike Kobler Date: Sat, 5 Oct 2019 18:52:17 -0500 Subject: [PATCH 5/8] Fix minor typos --- src/octoprint/templates/tabs/timelapse.jinja2 | 2 +- src/octoprint/translations/de/LC_MESSAGES/messages.po | 2 +- translations/de/LC_MESSAGES/messages.po | 2 +- translations/messages.pot | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/octoprint/templates/tabs/timelapse.jinja2 b/src/octoprint/templates/tabs/timelapse.jinja2 index ba2348e95..da134c733 100644 --- a/src/octoprint/templates/tabs/timelapse.jinja2 +++ b/src/octoprint/templates/tabs/timelapse.jinja2 @@ -26,7 +26,7 @@ {{ _('sec') }} - {{ _('OctoPrint will rate limit snapshots to this minimum interval. This it to prevent against performance issues with vase mode/continous z prints.') }} + {{ _('OctoPrint will rate limit snapshots to this minimum interval. This is to prevent against performance issues with vase mode/continous z prints.') }} diff --git a/src/octoprint/translations/de/LC_MESSAGES/messages.po b/src/octoprint/translations/de/LC_MESSAGES/messages.po index a3621f1ca..c18a1f4cd 100644 --- a/src/octoprint/translations/de/LC_MESSAGES/messages.po +++ b/src/octoprint/translations/de/LC_MESSAGES/messages.po @@ -5593,7 +5593,7 @@ msgid "Minimum interval" msgstr "Minimales Intervall" #: src/octoprint/templates/tabs/timelapse.jinja2:29 -msgid "OctoPrint will rate limit snapshots to this minimum interval. This it to prevent against performance issues with vase mode/continous z prints." +msgid "OctoPrint will rate limit snapshots to this minimum interval. This is to prevent against performance issues with vase mode/continous z prints." msgstr "OctoPrint wird Zeitrafferaufnahmen auf dieses minimale Intervall ratelimiten. Dies soll gegen Performanzprobleme bei Vase-Mode/Continuous-Z-Drucken helfen." #: src/octoprint/templates/tabs/timelapse.jinja2:34 diff --git a/translations/de/LC_MESSAGES/messages.po b/translations/de/LC_MESSAGES/messages.po index a3621f1ca..c18a1f4cd 100644 --- a/translations/de/LC_MESSAGES/messages.po +++ b/translations/de/LC_MESSAGES/messages.po @@ -5593,7 +5593,7 @@ msgid "Minimum interval" msgstr "Minimales Intervall" #: src/octoprint/templates/tabs/timelapse.jinja2:29 -msgid "OctoPrint will rate limit snapshots to this minimum interval. This it to prevent against performance issues with vase mode/continous z prints." +msgid "OctoPrint will rate limit snapshots to this minimum interval. This is to prevent against performance issues with vase mode/continous z prints." msgstr "OctoPrint wird Zeitrafferaufnahmen auf dieses minimale Intervall ratelimiten. Dies soll gegen Performanzprobleme bei Vase-Mode/Continuous-Z-Drucken helfen." #: src/octoprint/templates/tabs/timelapse.jinja2:34 diff --git a/translations/messages.pot b/translations/messages.pot index 0abcf19cd..8b30e3e2f 100644 --- a/translations/messages.pot +++ b/translations/messages.pot @@ -6132,7 +6132,7 @@ msgstr "" #: src/octoprint/templates/tabs/timelapse.jinja2:29 msgid "" -"OctoPrint will rate limit snapshots to this minimum interval. This it to " +"OctoPrint will rate limit snapshots to this minimum interval. This is to " "prevent against performance issues with vase mode/continous z prints." msgstr "" From fd62c1fa3d38cfc9963441336e38e57d1c1f4766 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 8 Oct 2019 16:40:29 +0200 Subject: [PATCH 6/8] =?UTF-8?q?=E2=98=94=20Set=20some=20more=20headers,=20?= =?UTF-8?q?remove=20CDN=20URL=20&=20remove=20unused=20JSESSIONID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Set X-Content-Type-Options to nosniff * Set X-Frame-Options to sameorigin (if not configured otherwise) * SockJS iframe fallback no longer embeds sockjs library from a CDN * SockJS no longer rewrites the unused JSESSIONID cookie --- src/octoprint/server/__init__.py | 10 ++++++++-- src/octoprint/server/api/settings.py | 5 ++++- src/octoprint/settings.py | 3 ++- src/octoprint/static/js/app/viewmodels/settings.js | 2 ++ src/octoprint/templates/dialogs/settings/server.jinja2 | 2 ++ .../snippets/settings/server/serverAllowFraming.jinja2 | 7 +++++++ 6 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 src/octoprint/templates/snippets/settings/server/serverAllowFraming.jinja2 diff --git a/src/octoprint/server/__init__.py b/src/octoprint/server/__init__.py index 9178ff4b3..db4322ce5 100644 --- a/src/octoprint/server/__init__.py +++ b/src/octoprint/server/__init__.py @@ -536,7 +536,9 @@ class Server(object): self._router = SockJSRouter(self._create_socket_connection, "/sockjs", session_kls=util.sockjs.ThreadSafeSession, - user_settings=dict(websocket_allow_origin="*" if enable_cors else "")) + user_settings=dict(websocket_allow_origin="*" if enable_cors else "", + jsessionid=False, + sockjs_url="../../static/js/lib/sockjs.min.js")) upload_suffixes = dict(name=self._settings.get(["server", "uploads", "nameSuffix"]), path=self._settings.get(["server", "uploads", "pathSuffix"])) @@ -647,7 +649,11 @@ class Server(object): self._logger.debug("Adding additional route {route} handled by handler {handler} and with additional arguments {kwargs!r}".format(**locals())) server_routes.append((route, handler, kwargs)) - headers = {"X-Robots-Tag": "noindex, nofollow, noimageindex"} + headers = {"X-Robots-Tag": "noindex, nofollow, noimageindex", + "X-Content-Type-Options": "nosniff"} + if not settings().getBoolean(["server", "allowFraming"]): + headers["X-Frame-Options"] = "sameorigin" + removed_headers = ["Server"] server_routes.append((r".*", util.tornado.UploadStorageFallbackHandler, dict(fallback=util.tornado.WsgiInputContainer(app.wsgi_app, diff --git a/src/octoprint/server/api/settings.py b/src/octoprint/server/api/settings.py index dd19e4d7a..2c5e79df1 100644 --- a/src/octoprint/server/api/settings.py +++ b/src/octoprint/server/api/settings.py @@ -236,7 +236,8 @@ def getSettings(): "enabled": s.getBoolean(["server", "pluginBlacklist", "enabled"]), "url": s.get(["server", "pluginBlacklist", "url"]), "ttl": int(s.getInt(["server", "pluginBlacklist", "ttl"]) / 60) - } + }, + "allowFraming": s.getBoolean(["server", "allowFraming"]) } } @@ -554,6 +555,8 @@ def _saveSettings(data): s.setInt(["server", "pluginBlacklist", "ttl"], ttl * 60) except ValueError: pass + if "allowFraming" in data["server"]: + s.setBoolean(["server", "allowFraming"], data["server"]["allowFraming"]) if "plugins" in data: for plugin in octoprint.plugin.plugin_manager().get_implementations(octoprint.plugin.SettingsPlugin): diff --git a/src/octoprint/settings.py b/src/octoprint/settings.py index 4cb92000d..1d9a87b20 100644 --- a/src/octoprint/settings.py +++ b/src/octoprint/settings.py @@ -214,7 +214,8 @@ default_settings = { "ipCheck": { "enabled": True, "trustedSubnets": [] - } + }, + "allowFraming": False }, "webcam": { "webcamEnabled": True, diff --git a/src/octoprint/static/js/app/viewmodels/settings.js b/src/octoprint/static/js/app/viewmodels/settings.js index 34a55a979..a51b6689f 100644 --- a/src/octoprint/static/js/app/viewmodels/settings.js +++ b/src/octoprint/static/js/app/viewmodels/settings.js @@ -244,6 +244,8 @@ $(function() { self.server_pluginBlacklist_url = ko.observable(); self.server_pluginBlacklist_ttl = ko.observable(); + self.server_allowFraming = ko.observable(); + self.settings = undefined; self.lastReceivedSettings = undefined; diff --git a/src/octoprint/templates/dialogs/settings/server.jinja2 b/src/octoprint/templates/dialogs/settings/server.jinja2 index b7f6c497e..f5b3cc8c7 100644 --- a/src/octoprint/templates/dialogs/settings/server.jinja2 +++ b/src/octoprint/templates/dialogs/settings/server.jinja2 @@ -1,4 +1,6 @@
+ {% include "snippets/settings/server/serverAllowFraming.jinja2" %} +

{{ _('Commands') }}

{% include "snippets/settings/server/serverCommandServerRestart.jinja2" %} diff --git a/src/octoprint/templates/snippets/settings/server/serverAllowFraming.jinja2 b/src/octoprint/templates/snippets/settings/server/serverAllowFraming.jinja2 new file mode 100644 index 000000000..b0442582f --- /dev/null +++ b/src/octoprint/templates/snippets/settings/server/serverAllowFraming.jinja2 @@ -0,0 +1,7 @@ +
+
+ +
+
From 7ee9bc32eb0a0b1dc28e6386ec316996734abdef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 9 Oct 2019 15:51:38 +0200 Subject: [PATCH 7/8] =?UTF-8?q?=E2=98=94=20Aggressive=20escaping?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugins/appkeys/static/js/appkeys.js | 12 ++++---- .../plugins/backup/static/js/backup.js | 18 +++++------ .../plugins/logging/static/js/logging.js | 8 ++--- .../pluginmanager/static/js/pluginmanager.js | 22 +++++++------- .../static/js/softwareupdate.js | 6 ++-- src/octoprint/static/js/app/dataupdater.js | 14 ++++----- .../static/js/app/viewmodels/files.js | 18 +++++------ .../static/js/app/viewmodels/loginstate.js | 4 +-- .../js/app/viewmodels/printerprofiles.js | 4 +-- .../static/js/app/viewmodels/settings.js | 2 +- .../static/js/app/viewmodels/slicing.js | 2 +- .../static/js/app/viewmodels/system.js | 6 ++-- .../static/js/app/viewmodels/temperature.js | 6 ++-- .../static/js/app/viewmodels/timelapse.js | 30 +++++++++---------- 14 files changed, 76 insertions(+), 76 deletions(-) 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 consult octoprint.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 += "

  • " - + _.sprintf(line, {plugin: step.plugin, result: step.result ? "" : ""}) + + _.sprintf(line, {plugin: _.escape(step.plugin), result: step.result ? "" : ""}) + "
  • "; }); text += "

    "; @@ -934,16 +934,16 @@ $(function() { var title; if (important) { - title = _.sprintf(gettext("Important notice regarding plugin \"%(name)s\""), {name: name}); + title = _.sprintf(gettext("Important notice regarding plugin \"%(name)s\""), {name: _.escape(name)}); } else { - title = _.sprintf(gettext("Notice regarding plugin \"%(name)s\""), {name: name}); + title = _.sprintf(gettext("Notice regarding plugin \"%(name)s\""), {name: _.escape(name)}); } var text = ""; if (notification.versions && notification.versions.length > 0) { var versions = _.map(notification.versions, function(v) { return (v == version) ? "" + v + "" : v; }).join(", "); - text += "" + _.sprintf(gettext("Affected versions: %(versions)s"), {versions: versions}) + ""; + text += "" + _.sprintf(gettext("Affected versions: %(versions)s"), {versions: _.escape(versions)}) + ""; } else { text += "" + gettext("Affected versions: all") + ""; } diff --git a/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js b/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js index 249eb8937..706e33696 100644 --- a/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js +++ b/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js @@ -216,13 +216,13 @@ $(function() { } var fullNameTemplate = gettext("%(name)s: %(version)s"); - value.fullNameLocal = _.sprintf(fullNameTemplate, {name: value.displayName, version: value.displayVersion}); + value.fullNameLocal = _.sprintf(fullNameTemplate, {name: _.escape(value.displayName), version: _.escape(value.displayVersion)}); var fullNameRemoteVars = {name: value.displayName, version: gettext("unknown")}; if (value.hasOwnProperty("information") && value.information.hasOwnProperty("remote") && value.information.remote.hasOwnProperty("name")) { fullNameRemoteVars.version = value.information.remote.name; } - value.fullNameRemote = _.sprintf(fullNameTemplate, fullNameRemoteVars); + value.fullNameRemote = _.sprintf(fullNameTemplate, _.escape(fullNameRemoteVars)); versions.push(value); }); @@ -656,7 +656,7 @@ $(function() { case "updating": { console.log(JSON.stringify(messageData)); - text = _.sprintf(gettext("Now updating %(name)s to %(version)s"), {name: messageData.name, version: messageData.version}); + text = _.sprintf(gettext("Now updating %(name)s to %(version)s"), {name: _.escape(messageData.name), version: _.escape(messageData.version)}); self.loglines.push({line: "", stream: "separator"}); self.loglines.push({line: _.repeat("+", text.length), stream: "separator"}); self.loglines.push({line: text, stream: "message"}); diff --git a/src/octoprint/static/js/app/dataupdater.js b/src/octoprint/static/js/app/dataupdater.js index 5d2ba8804..4f1185d51 100644 --- a/src/octoprint/static/js/app/dataupdater.js +++ b/src/octoprint/static/js/app/dataupdater.js @@ -174,7 +174,7 @@ function DataUpdater(allViewModels, connectCallback, disconnectCallback) { self._safeModePopup = new PNotify({ title: gettext("Safe mode is active"), - 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: 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) { From 270a0dcb1f6e9b3b002d8b150ab109e32dca80ae Mon Sep 17 00:00:00 2001 From: Ludovico de Nittis Date: Fri, 11 Oct 2019 22:41:58 +0200 Subject: [PATCH 8/8] Fix systemd service documentation path The previously suggested `service` folder is not available in a canonical systemd installation. Instead new services should be placed in `/etc/systemd/system/` --- AUTHORS.md | 1 + scripts/README.md | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/AUTHORS.md b/AUTHORS.md index 7c5951d33..17c8c7670 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -109,6 +109,7 @@ date of first contribution): * [Aliaksei Pilko](https://github.com/aliaksei135) * [Ben Yarmis](https://github.com/byarmis) * [Florian Heilmann](https://github.com/FHeilmann) + * [Ludovico de Nittis](https://github.com/RyuzakiKK) OctoPrint started off as a fork of [Cura](https://github.com/daid/Cura) by [Daid Braam](https://github.com/daid). Parts of its communication layer and diff --git a/scripts/README.md b/scripts/README.md index 8fbc44621..51da00e50 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -13,5 +13,5 @@ octoprint.init => /etc/init.d/octoprint ## systemd ``` -octoprint.service => /etc/systemd/service/octoprint.service +octoprint.service => /etc/systemd/system/octoprint.service ```