From 5b606b143c3fb9c5641ec6bc0d728ebe2f800dee Mon Sep 17 00:00:00 2001 From: Esther Goldberg <30660571+Esther-Goldberg@users.noreply.github.com> Date: Tue, 9 Apr 2024 09:57:57 -0400 Subject: Raise error if attachment pathname contains invalid bytes (#209) --- tests/test_nsjail.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests') diff --git a/tests/test_nsjail.py b/tests/test_nsjail.py index d54d31b..dde20bc 100644 --- a/tests/test_nsjail.py +++ b/tests/test_nsjail.py @@ -250,6 +250,20 @@ class NsJailTests(unittest.TestCase): ) self.assertEqual(result.stderr, None) + def test_filename_encoding_illegal_chars(self): + code = dedent( + r""" + with open(b"\xC3.txt", "w") as f: + f.write("test") + """ + ).strip() + result = self.eval_file(code) + self.assertEqual(result.returncode, None) + self.assertEqual( + result.stdout, "FileParsingError: invalid bytes in filename while parsing attachments" + ) + self.assertEqual(result.stderr, None) + def test_file_parsing_depth_limit(self): code = dedent( """ -- cgit v1.2.3