Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The redirect parameter to the login dialog now gets restricted to local URLs (as detected by unset scheme & netloc) that match a short list of allowed endpoints routes.
- Loading branch information
Showing
3 changed files
with
63 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
__license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html" | ||
__copyright__ = "Copyright (C) 2022 The OctoPrint Project - Released under terms of the AGPLv3 License" | ||
|
||
import pytest | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"url,paths,expected", | ||
[ | ||
# various default UI URLs | ||
("/", ["/", "/recovery/"], True), | ||
("/?", ["/", "/recovery/"], True), | ||
("/?l10n=de", ["/", "/recovery/"], True), | ||
("/?l10n=de&", ["/", "/recovery/"], True), | ||
("/octoprint/", ["/octoprint/", "/octoprint/recovery/"], True), | ||
# various recovery URLs | ||
("/recovery/", ["/", "/recovery/"], True), | ||
("/recovery/?", ["/", "/recovery/"], True), | ||
("/recovery/?l10n=de", ["/", "/recovery/"], True), | ||
("/octoprint/recovery/?l10n=de", ["/octoprint/", "/octoprint/recovery/"], True), | ||
# various external URLs | ||
("http://example.com", ["/", "/recovery/"], False), | ||
("https://example.com", ["/", "/recovery/"], False), | ||
("//example.com", ["/", "/recovery/"], False), | ||
("/\\/\\example.com", ["/", "/recovery/"], False), | ||
(" /\\/\\example.com", ["/", "/recovery/"], False), | ||
("\\/\\/example.com", ["/", "/recovery/"], False), | ||
(" \\/\\/example.com", ["/", "/recovery/"], False), | ||
# other stuff | ||
("javascript:alert(document.cookie)", ["/", "/recovery/"], False), | ||
], | ||
) | ||
def test_validate_local_redirect(url, paths, expected): | ||
from octoprint.server.util import validate_local_redirect | ||
|
||
assert validate_local_redirect(url, paths) == expected |
dabdd40
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit has been mentioned on OctoPrint Community Forum. There might be relevant details there:
https://community.octoprint.org/t/octoprint-goes-to-sleep-after-upgrade-to-1-8-2/46070/14