diff --git a/.github/workflows/nightly_merge.yml b/.github/workflows/nightly_merge.yml index fc74e5415..089f44c8c 100644 --- a/.github/workflows/nightly_merge.yml +++ b/.github/workflows/nightly_merge.yml @@ -15,7 +15,7 @@ jobs: fetch-depth: 0 - name: 🔀 Merge master into maintenance - uses: robotology/gh-action-nightly-merge@v1.3.2 + uses: robotology/gh-action-nightly-merge@v1.3.3 with: stable_branch: "master" development_branch: "maintenance" @@ -24,7 +24,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: 🔀 Merge maintenance into devel - uses: robotology/gh-action-nightly-merge@v1.3.2 + uses: robotology/gh-action-nightly-merge@v1.3.3 with: stable_branch: "maintenance" development_branch: "devel" diff --git a/AUTHORS.md b/AUTHORS.md index b33aad895..6542ddb5b 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -166,6 +166,7 @@ date of first contribution): * [Johan Verrept](https://github.com/JoveToo) * [Nicu Surdu](https://github.com/surdu) * [Zack Lewis](https://github.com/lima3w) + * [Billy Richardson](https://github.com/richardsondev) 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/SUPPORTERS.md b/SUPPORTERS.md index 94ed52f15..07d92e921 100644 --- a/SUPPORTERS.md +++ b/SUPPORTERS.md @@ -8,6 +8,7 @@ thanks to everyone who contributed! * 3D-TECH * 3DPrinterOS + * Al Mucci * Arnljot Arntsen * Artillery 3D * Ash King @@ -37,6 +38,7 @@ thanks to everyone who contributed! * James Mackay * Jeff Green * Jeff Moe + * jeffiel * Jeremy Cole * Joshua Wills * Julian Melo @@ -67,6 +69,7 @@ thanks to everyone who contributed! * Richard Stocks * Robert Gusek * Ronald Griehsler + * Sean Jensen-Grey * Sebastien Andrivet * Stefan Krister * Steve Dougherty @@ -78,4 +81,4 @@ thanks to everyone who contributed! * Ulrich Kempken * Yehuda Katz -and 2307 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel) or via [GitHub Sponsors](https://github.com/users/foosel/sponsorship)! +and 2279 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel) or via [GitHub Sponsors](https://github.com/users/foosel/sponsorship)! diff --git a/babel.cfg b/babel.cfg index 9117d82ce..fe1119625 100644 --- a/babel.cfg +++ b/babel.cfg @@ -2,11 +2,11 @@ [jinja2: src/octoprint/templates/**.jinja2] silent=false -extensions=jinja2.ext.autoescape, jinja2.ext.with_, webassets.ext.jinja2.AssetsExtension, jinja2.ext.do, octoprint.util.jinja.trycatch +extensions=webassets.ext.jinja2.AssetsExtension, jinja2.ext.do, octoprint.util.jinja.trycatch [jinja2: src/octoprint/plugins/**.jinja2] silent=false -extensions=jinja2.ext.autoescape, jinja2.ext.with_, webassets.ext.jinja2.AssetsExtension, jinja2.ext.do, octoprint.util.jinja.trycatch +extensions=webassets.ext.jinja2.AssetsExtension, jinja2.ext.do, octoprint.util.jinja.trycatch [javascript: src/octoprint/static/js/app/**.js] extract_messages = gettext, ngettext diff --git a/docs/api/datamodel.rst b/docs/api/datamodel.rst index 24a10f904..595c91d0d 100644 --- a/docs/api/datamodel.rst +++ b/docs/api/datamodel.rst @@ -649,7 +649,7 @@ Permission record * - ``dangerous`` - 1 - boolean - - Whether the permission should be considered dangerous due to a high reponsibility (true) or not (false). + - Whether the permission should be considered dangerous due to a high responsibility (true) or not (false). * - ``default_groups`` - 1 - List of string diff --git a/docs/configuration/config_yaml.rst b/docs/configuration/config_yaml.rst index 1a87e4157..e1c126dcb 100644 --- a/docs/configuration/config_yaml.rst +++ b/docs/configuration/config_yaml.rst @@ -452,7 +452,7 @@ Use the following settings to enable or disable OctoPrint features: # whether G90/G91 also influence absolute/relative mode of extruders g90InfluencesExtruder: false - # Replace all special characters and spaces with text equivalent to make them univerally compatible. + # Replace all special characters and spaces with text equivalent to make them universally compatible. # Most OS filesystems work fine with unicode characters, but just in case you can revert to the # older behaviour by setting this to true. enforceReallyUniversalFilenames: false diff --git a/docs/development/virtual_printer.rst b/docs/development/virtual_printer.rst index 5e7a31e4d..f0d96138f 100644 --- a/docs/development/virtual_printer.rst +++ b/docs/development/virtual_printer.rst @@ -216,7 +216,7 @@ There many configuration options via ``config.yaml`` for the virtual printer tha # Enable virtual EEPROM # If enabled, a file `eeprom.json` will be created in the plugin data folder - # to enable settings persistence across connections. Enables M500/1/2/4 commmands + # to enable settings persistence across connections. Enables M500/1/2/4 commands # And a selection of other settings commands. Responses modeled on Marlin 2.0 enable_eeprom: true diff --git a/docs/features/accesscontrol.rst b/docs/features/accesscontrol.rst index 1c3ee2583..218e3bb9c 100644 --- a/docs/features/accesscontrol.rst +++ b/docs/features/accesscontrol.rst @@ -133,7 +133,7 @@ Example: Your PC has an IP address of ``192.168.23.42`` and a subnet mask of The easy way: Using the OctoPrint-AutoLoginConfig plugin ........................................................ -The easist way to configure AutoLogin is to install the +The easiest way to configure AutoLogin is to install the `OctoPrint-AutoLoginConfig plugin `_ via the plugin manager. diff --git a/docs/plugins/hooks.rst b/docs/plugins/hooks.rst index 815482ac3..6d1b32709 100644 --- a/docs/plugins/hooks.rst +++ b/docs/plugins/hooks.rst @@ -1911,7 +1911,7 @@ octoprint.timelapse.capture.post Perform specific actions after capturing a timelapse frame. ``filename`` will be the path of the frame that should have been saved. - ``sucesss`` indicates whether the capture was successful or not. + ``success`` indicates whether the capture was successful or not. :param str filename: The path of the frame that should have been saved. :param boolean success: Indicates whether the capture was successful or not. diff --git a/docs/plugins/python3_migration.rst b/docs/plugins/python3_migration.rst index 170e039e7..cbf9ccaf4 100644 --- a/docs/plugins/python3_migration.rst +++ b/docs/plugins/python3_migration.rst @@ -336,7 +336,7 @@ As a summary, follow this checklist to migrate your plugin to be compatible to b # -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function, unicode_literals - * Thorougly test your plugin under Python 3. Pay special attention to any kind of string handling issues, integer + * Thoroughly test your plugin under Python 3. Pay special attention to any kind of string handling issues, integer division, relative imports from your plugin package and how the results of ``map``, ``filter`` and ``zip`` are used in your code, as those have proven to be the biggest issues during past migrations. * Once everything works under both Python versions and you've prepared a new release of your plugin (don't forget to diff --git a/src/octoprint/plugin/types.py b/src/octoprint/plugin/types.py index b6c7241d8..338fb9929 100644 --- a/src/octoprint/plugin/types.py +++ b/src/octoprint/plugin/types.py @@ -500,7 +500,7 @@ class TemplatePlugin(OctoPrintPlugin, ReloadNeedingPlugin): :widths: 5 95 * - icon - - Icon to use for the sidebar header, should be the name of a Font Awesome icon without the leading ``icon-`` part. + - Icon to use for the sidebar header, should be the full name of a Font Awesome icon including the ``fas``/``far``/``fab`` prefix, eg. ``fas fa-plus``. * - template_header - Additional template to include in the head section of the sidebar item. For an example of this, see the additional options included in the "Files" section. diff --git a/src/octoprint/plugins/action_command_notification/__init__.py b/src/octoprint/plugins/action_command_notification/__init__.py index 3b3ae1c10..9ed83c20f 100644 --- a/src/octoprint/plugins/action_command_notification/__init__.py +++ b/src/octoprint/plugins/action_command_notification/__init__.py @@ -95,7 +95,7 @@ class ActionCommandNotificationPlugin( { "type": "sidebar", "name": gettext("Printer Notifications"), - "icon": "bell-o", + "icon": "far fa-bell", "styles_wrapper": ["display: none"], "template_header": "action_command_notification_sidebar_header.jinja2", "data_bind": "visible: loginState.hasPermissionKo(access.permissions.PLUGIN_ACTION_COMMAND_NOTIFICATION_SHOW)" diff --git a/src/octoprint/plugins/errortracking/__init__.py b/src/octoprint/plugins/errortracking/__init__.py index ad47d8a25..65b1a597d 100644 --- a/src/octoprint/plugins/errortracking/__init__.py +++ b/src/octoprint/plugins/errortracking/__init__.py @@ -18,10 +18,10 @@ from octoprint.util.version import ( ) SENTRY_URL_SERVER = ( - "https://890bd6bca44a4b7e92918b0ba74049ca@o118517.ingest.sentry.io/1373987" + "https://0d173c8b74b945e1bdc73443e543ddee@o118517.ingest.sentry.io/1373987" ) SENTRY_URL_COREUI = ( - "https://1f4ba2d14bfc4b1c9a861fde1c1d452d@o118517.ingest.sentry.io/1374096" + "https://f38a3d0ad2694f7f8672b1a2485c3820@o118517.ingest.sentry.io/1374096" ) SETTINGS_DEFAULTS = { diff --git a/src/octoprint/plugins/pluginmanager/templates/pluginmanager_settings.jinja2 b/src/octoprint/plugins/pluginmanager/templates/pluginmanager_settings.jinja2 index b4c1b5f25..f197d70be 100644 --- a/src/octoprint/plugins/pluginmanager/templates/pluginmanager_settings.jinja2 +++ b/src/octoprint/plugins/pluginmanager/templates/pluginmanager_settings.jinja2 @@ -266,7 +266,7 @@
diff --git a/src/octoprint/plugins/softwareupdate/templates/softwareupdate_settings.jinja2 b/src/octoprint/plugins/softwareupdate/templates/softwareupdate_settings.jinja2 index b8d8df41e..960bf2604 100644 --- a/src/octoprint/plugins/softwareupdate/templates/softwareupdate_settings.jinja2 +++ b/src/octoprint/plugins/softwareupdate/templates/softwareupdate_settings.jinja2 @@ -37,7 +37,7 @@ There is not enough free disk space available to run an update.

- To reduce the likelihood of running into update problems due to insuffient disk space, OctoPrint requires + To reduce the likelihood of running into update problems due to insufficient disk space, OctoPrint requires a minimum of {{ min_free_storage }} free disk space in various locations:

{% endtrans %} diff --git a/src/octoprint/server/__init__.py b/src/octoprint/server/__init__.py index 9eb075da0..b84ed7e70 100644 --- a/src/octoprint/server/__init__.py +++ b/src/octoprint/server/__init__.py @@ -1356,6 +1356,7 @@ class Server: app.config["TEMPLATES_AUTO_RELOAD"] = True app.config["JSONIFY_PRETTYPRINT_REGULAR"] = False + app.config["REMEMBER_COOKIE_HTTPONLY"] = True # we must not set this before TEMPLATES_AUTO_RELOAD is set to True or that won't take app.debug = self._debug @@ -2129,8 +2130,8 @@ class Server: "css/bootstrap-slider.css", "css/bootstrap-tabdrop.css", "vendor/font-awesome-3.2.1/css/font-awesome.min.css", - "vendor/font-awesome-5.15.1/css/all.min.css", - "vendor/font-awesome-5.15.1/css/v4-shims.min.css", + "vendor/fontawesome-6.1.1/css/all.min.css", + "vendor/fontawesome-6.1.1/css/v4-shims.min.css", "css/jquery.fileupload-ui.css", "css/pnotify.core.min.css", "css/pnotify.buttons.min.css", diff --git a/src/octoprint/server/views.py b/src/octoprint/server/views.py index 26e31ae17..a5d67c56b 100644 --- a/src/octoprint/server/views.py +++ b/src/octoprint/server/views.py @@ -8,6 +8,7 @@ import logging import os import re from collections import defaultdict +from urllib.parse import urlparse from flask import ( Response, @@ -170,7 +171,16 @@ def _add_additional_assets(hook_name): def login(): from flask_login import current_user - redirect_url = request.args.get("redirect", request.script_root + url_for("index")) + default_redirect_url = request.script_root + url_for("index") + redirect_url = request.args.get("redirect", default_redirect_url) + + parsed = urlparse(redirect_url) # check if redirect url is valid + if parsed.scheme != "" or parsed.netloc != "": + _logger.warning( + f"Got an invalid redirect URL with the login attempt, misconfiguration or attack attempt: {redirect_url}" + ) + redirect_url = default_redirect_url + permissions = sorted( filter( lambda x: x is not None and isinstance(x, OctoPrintPermission), diff --git a/src/octoprint/static/js/app/helpers.js b/src/octoprint/static/js/app/helpers.js index fcea464ef..fe6b9d649 100644 --- a/src/octoprint/static/js/app/helpers.js +++ b/src/octoprint/static/js/app/helpers.js @@ -652,13 +652,25 @@ function cleanTemperature(temp, offThreshold) { return temp; } -function formatTemperature(temp, showF, offThreshold) { +function formatTemperature(temp, showF, offThreshold, returnUnicode) { if (temp === undefined || !_.isNumber(temp)) return "-"; if (offThreshold !== undefined && temp < offThreshold) return gettext("off"); + + var degreeSymbol = "°"; + if (returnUnicode !== undefined && returnUnicode) { + degreeSymbol = "\u00B0"; + } + if (showF) { - return _.sprintf("%.1f°C (%.1f°F)", temp, (temp * 9) / 5 + 32); + return _.sprintf( + "%.1f%sC (%.1f%sF)", + temp, + degreeSymbol, + (temp * 9) / 5 + 32, + degreeSymbol + ); } else { - return _.sprintf("%.1f°C", temp); + return _.sprintf("%.1f%sC", temp, degreeSymbol); } } @@ -1542,41 +1554,75 @@ var copyToClipboard = function (text) { temp.remove(); }; -var determineWebcamStreamType = function (streamUrl) { - if (streamUrl) { - if (streamUrl.startsWith("webrtc")) { - return "webrtc"; - } +var getExternalHostUrl = function () { + var loc = window.location; + var port = ""; + if ( + (loc.protocol === "http:" && loc.port !== "80") || + (loc.protocol === "https:" && loc.port !== "443") + ) { + port = ":" + loc.port; + } + return loc.protocol + "//" + loc.hostname + port; +}; - var lastDotPosition = streamUrl.lastIndexOf("."); - var firstQuotationSignPosition = streamUrl.indexOf("?"); - if ( - lastDotPosition != -1 && - firstQuotationSignPosition != -1 && - lastDotPosition >= firstQuotationSignPosition - ) { - throw "Malformed URL. Cannot determine stream type."; - } +var validateWebcamUrl = function (streamUrl) { + if (!streamUrl) { + return false; + } - // If we have found a dot, try to extract the extension. - if (lastDotPosition > -1) { - if (firstQuotationSignPosition > -1) { - var extension = streamUrl.slice( - lastDotPosition + 1, - firstQuotationSignPosition - 1 - ); - } else { - var extension = streamUrl.slice(lastDotPosition + 1); - } - if (extension.toLowerCase() == "m3u8") { - return "hls"; - } - } - // By default, 'mjpg' is the stream type. - return "mjpg"; + var lower = streamUrl.toLowerCase(); + var toParse = streamUrl; + + if (lower.startsWith("//")) { + // protocol relative + toParse = window.location.protocol + streamUrl; + } else if (lower.startsWith("/")) { + // host relative + toParse = getExternalHostUrl() + streamUrl; + } else if ( + lower.startsWith("http:") || + lower.startsWith("https:") || + lower.startsWith("webrtc:") || + lower.startsWith("webrtcs:") + ) { + // absolute & supported protocol + toParse = streamUrl; } else { + return false; + } + + try { + return new URL(toParse); + } catch (e) { + return false; + } +}; + +var determineWebcamStreamType = function (streamUrl) { + if (!streamUrl) { throw "Empty streamUrl. Cannot determine stream type."; } + + var parsed = validateWebcamUrl(streamUrl); + if (!parsed) { + throw "Invalid streamUrl. Cannot determine stream type."; + } + + if (parsed.protocol === "webrtc:" || parsed.protocol === "webrtcs:") { + return "webrtc"; + } + + var lastDotPosition = parsed.pathname.lastIndexOf("."); + if (lastDotPosition !== -1) { + var extension = parsed.pathname.substring(lastDotPosition + 1); + if (extension.toLowerCase() === "m3u8") { + return "hls"; + } + } + + // By default, 'mjpg' is the stream type. + return "mjpg"; }; var saveToLocalStorage = function (key, data) { diff --git a/src/octoprint/static/js/app/viewmodels/control.js b/src/octoprint/static/js/app/viewmodels/control.js index 38431100e..ca8c4cb4b 100644 --- a/src/octoprint/static/js/app/viewmodels/control.js +++ b/src/octoprint/static/js/app/viewmodels/control.js @@ -573,7 +573,7 @@ $(function () { } // Determine stream type and switch to corresponding webcam. - var streamType = determineWebcamStreamType(self.settings.webcam_streamUrl()); + var streamType = self.settings.webcam_streamType(); if (streamType == "mjpg") { self._switchToMjpgWebcam(); } else if (streamType == "hls") { @@ -728,9 +728,12 @@ $(function () { // z home button = $("#control-zhome"); break; - default: + case 9: // prevent tab key from removing focus from webcam event.preventDefault(); return false; + default: + // don't prevent other keys + return true; } if (button === undefined) { @@ -760,7 +763,7 @@ $(function () { return; } - var newSrc = self.settings.webcam_streamUrl(); + var newSrc = self.settings.webcam_streamUrlEscaped(); if (currentSrc != newSrc) { if (self.settings.webcam_cacheBuster()) { if (newSrc.lastIndexOf("?") > -1) { @@ -797,10 +800,10 @@ $(function () { typeof video.canPlayType != undefined && video.canPlayType("application/vnd.apple.mpegurl") == "probably" ) { - video.src = self.settings.webcam_streamUrl(); + video.src = self.settings.webcam_streamUrlEscaped(); } else if (Hls.isSupported()) { self.hls = new Hls(); - self.hls.loadSource(self.settings.webcam_streamUrl()); + self.hls.loadSource(self.settings.webcam_streamUrlEscaped()); self.hls.attachMedia(video); } @@ -836,7 +839,7 @@ $(function () { if (self.webRTCPeerConnection == null) { self.webRTCPeerConnection = startWebRTC( video, - self.settings.webcam_streamUrl(), + self.settings.webcam_streamUrlEscaped(), self.settings.webcam_streamWebrtcIceServers() ); } diff --git a/src/octoprint/static/js/app/viewmodels/settings.js b/src/octoprint/static/js/app/viewmodels/settings.js index 838c56735..bf56727c3 100644 --- a/src/octoprint/static/js/app/viewmodels/settings.js +++ b/src/octoprint/static/js/app/viewmodels/settings.js @@ -312,13 +312,20 @@ $(function () { self.webcam_ffmpegPathOk(false); self.webcam_ffmpegPathBroken(false); }; + self.webcam_streamUrlEscaped = ko.pureComputed(function () { + return encodeURI(self.webcam_streamUrl()); + }); self.webcam_streamType = ko.pureComputed(function () { try { - return determineWebcamStreamType(self.webcam_streamUrl()); + return determineWebcamStreamType(self.webcam_streamUrlEscaped()); } catch (e) { return ""; } }); + self.webcam_streamValid = ko.pureComputed(function () { + var url = self.webcam_streamUrlEscaped(); + return !url || validateWebcamUrl(url); + }); self.server_onlineCheckText = ko.observable(); self.server_onlineCheckOk = ko.observable(false); @@ -439,7 +446,8 @@ $(function () { self.testWebcamStreamUrlBusy = ko.observable(false); self.testWebcamStreamUrl = function () { - if (!self.webcam_streamUrl()) { + var url = self.webcam_streamUrlEscaped(); + if (!url) { return; } @@ -450,24 +458,31 @@ $(function () { var text = gettext( "If you see your webcam stream below, the entered stream URL is ok." ); - var streamType = self.webcam_streamType(); + + var streamType; + try { + streamType = self.webcam_streamType(); + } catch (e) { + streamType = ""; + } + var webcam_element; var webrtc_peer_connection; - if (streamType == "mjpg") { - webcam_element = $(''); - } else if (streamType == "hls") { + if (streamType === "mjpg") { + webcam_element = $(''); + } else if (streamType === "hls") { webcam_element = $( '