From 21657acf52bf068133f638dd3904d329d254fc98 Mon Sep 17 00:00:00 2001 From: daftshady Date: Mon, 9 Mar 2015 13:06:33 +0900 Subject: [PATCH] temporarily fixed double slash redirect issue --- tornado/test/web_test.py | 6 ++++++ tornado/web.py | 3 +-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tornado/test/web_test.py b/tornado/test/web_test.py index f3c8505ad..a52f16678 100644 --- a/tornado/test/web_test.py +++ b/tornado/test/web_test.py @@ -597,6 +597,7 @@ class WSGISafeWebTest(WebTestCase): url("/redirect", RedirectHandler), url("/web_redirect_permanent", WebRedirectHandler, {"url": "/web_redirect_newpath"}), url("/web_redirect", WebRedirectHandler, {"url": "/web_redirect_newpath", "permanent": False}), + url("//web_redirect_double_slash", WebRedirectHandler, {"url": '/web_redirect_newpath'}), url("/header_injection", HeaderInjectionHandler), url("/get_argument", GetArgumentHandler), url("/get_arguments", GetArgumentsHandler), @@ -730,6 +731,11 @@ js_embed() self.assertEqual(response.code, 302) self.assertEqual(response.headers['Location'], '/web_redirect_newpath') + def test_web_redirect_double_slash(self): + response = self.fetch("//web_redirect_double_slash", follow_redirects=False) + self.assertEqual(response.code, 301) + self.assertEqual(response.headers['Location'], '/web_redirect_newpath') + def test_header_injection(self): response = self.fetch("/header_injection") self.assertEqual(response.body, b"ok") diff --git a/tornado/web.py b/tornado/web.py index 62f3779df..155da550d 100644 --- a/tornado/web.py +++ b/tornado/web.py @@ -650,8 +650,7 @@ class RequestHandler(object): else: assert isinstance(status, int) and 300 <= status <= 399 self.set_status(status) - self.set_header("Location", urlparse.urljoin(utf8(self.request.uri), - utf8(url))) + self.set_header("Location", utf8(url)) self.finish() def write(self, chunk): -- 2.47.2