From 5fc747a64edb2f3a291c2725d34e965a9552b22f Mon Sep 17 00:00:00 2001 From: Emil Mikulic Date: Wed, 1 Jul 2020 20:01:56 +1000 Subject: [PATCH] Add tests for fetching a file with a question mark in its name. --- devel/test.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/devel/test.py b/devel/test.py index 67db2a9..e6a5bd1 100755 --- a/devel/test.py +++ b/devel/test.py @@ -249,14 +249,19 @@ class TestDirRedirect(TestHelper): class TestFileGet(TestHelper): def setUp(self): self.datalen = 2345 - self.data = "".join( + self.data = ''.join( [chr(random.randint(0,255)) for _ in xrange(self.datalen)]) - self.url = "/data.jpeg" + self.url = '/data.jpeg' self.fn = WWWROOT + self.url - open(self.fn, "w").write(self.data) + with open(self.fn, "w") as f: + f.write(self.data) + self.qurl = '/what%3f.jpg' + self.qfn = WWWROOT + '/what?.jpg' + os.link(self.fn, self.qfn) def tearDown(self): os.unlink(self.fn) + os.unlink(self.qfn) def get_helper(self, url): resp = self.get(url) @@ -278,12 +283,18 @@ class TestFileGet(TestHelper): def test_file_get_redundant_dots(self): self.get_helper("/././." + self.url) - def test_file_get_question(self): + def test_file_get_with_empty_query(self): self.get_helper(self.url + "?") - def test_file_get_question_query(self): + def test_file_get_with_query(self): self.get_helper(self.url + "?action=Submit") + def test_file_get_esc_question(self): + self.get_helper(self.qurl) + + def test_file_get_esc_question_with_query(self): + self.get_helper(self.qurl + '?hello=world') + def test_file_head(self): resp = self.get(self.url, method="HEAD") status, hdrs, body = parse(resp)