From 1035a24707276a97c75a6fd1ecf9f425fb01fc10 Mon Sep 17 00:00:00 2001 From: jfriedli Date: Sun, 12 Jan 2025 12:11:06 +0000 Subject: Added Non-Ascii filename support --- test/test.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'test/test.py') diff --git a/test/test.py b/test/test.py index 4d2907f..d5ef52d 100644 --- a/test/test.py +++ b/test/test.py @@ -187,17 +187,28 @@ class Mat2WebTestCase(TestCase): self.assertIn(b'.mp2', rv.data) self.assertEqual(rv.status_code, 200) - def test_get_upload_naughty_input(self): + def test_get_upload_no_ascii_no_ext_input(self): rv = self.client.post( '/', data=dict( - file=(io.BytesIO(b"a"), '﷽'), + file=(io.BytesIO(b"a"), '﷽.txt'), ), follow_redirects=True ) self.assertEqual(rv.status_code, 200) - self.assertIn(b'Invalid Filename', rv.data) + self.assertIn(b'.cleaned.txt', rv.data) + def test_get_upload_no_ascii_stem_input(self): + pdfBytes = b"%PDF-1.\n 1 0 obj<>endobj\n2 0 obj<>endobj\n3 0 obj<>endobj\ntrailer <>" + rv = self.client.post( + '/', + data=dict( + file=(io.BytesIO(pdfBytes), '한국어.pdf'), + ), + follow_redirects=True + ) + self.assertEqual(rv.status_code, 200) + self.assertIn(b'.cleaned.pdf', rv.data) if __name__ == '__main__': unittest.main() -- cgit v1.3