Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

web_test: Fix open redirect test on windows #3305

Merged
merged 1 commit into from
Aug 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions tornado/test/web_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1457,10 +1457,18 @@ def test_no_open_redirect(self):
# This test verifies that the open redirect that affected some configurations
# prior to Tornado 6.3.2 is no longer possible. The vulnerability required
# a static_url_prefix of "/" and a default_filename (any value) to be set.
# The absolute server-side path to the static directory must also be known.
# The absolute* server-side path to the static directory must also be known.
#
# * Almost absolute: On windows, the drive letter is stripped from the path.
test_dir = os.path.dirname(__file__)
drive, tail = os.path.splitdrive(test_dir)
if os.name == "posix":
self.assertEqual(tail, test_dir)
else:
test_dir = tail
with ExpectLog(gen_log, ".*cannot redirect path with two initial slashes"):
response = self.fetch(
f"//evil.com/../{os.path.dirname(__file__)}/static/dir",
f"//evil.com/../{test_dir}/static/dir",
follow_redirects=False,
)
self.assertEqual(response.code, 403)
Expand Down