diff --git a/swift/common/swob.py b/swift/common/swob.py index df94233360..6b61b9a153 100755 --- a/swift/common/swob.py +++ b/swift/common/swob.py @@ -703,7 +703,7 @@ class Request(object): 'REQUEST_METHOD': 'GET', 'SCRIPT_NAME': '', 'QUERY_STRING': query_string, - 'PATH_INFO': path_info, + 'PATH_INFO': urllib2.unquote(path_info), 'SERVER_NAME': 'localhost', 'SERVER_PORT': '80', 'HTTP_HOST': 'localhost:80', @@ -749,7 +749,7 @@ class Request(object): def path(self): "Provides the full path of the request, excluding the QUERY_STRING" return urllib2.quote(self.environ.get('SCRIPT_NAME', '') + - self.environ['PATH_INFO'].split('?')[0]) + self.environ['PATH_INFO']) def path_info_pop(self): """ diff --git a/test/unit/common/test_swob.py b/test/unit/common/test_swob.py index 44c41c98b8..f676daa7e8 100755 --- a/test/unit/common/test_swob.py +++ b/test/unit/common/test_swob.py @@ -290,6 +290,13 @@ class TestRequest(unittest.TestCase): '/', environ={'SCRIPT_NAME': '/hi', 'PATH_INFO': '/there'}) self.assertEquals(req.path, '/hi/there') + def test_path_question_mark(self): + req = swift.common.swob.Request.blank('/test%3Ffile') + # This tests that .blank unquotes the path when setting PATH_INFO + self.assertEquals(req.environ['PATH_INFO'], '/test?file') + # This tests that .path requotes it + self.assertEquals(req.path, '/test%3Ffile') + def test_path_info_pop(self): req = swift.common.swob.Request.blank('/hi/there') self.assertEquals(req.path_info_pop(), 'hi')