diff options
Diffstat (limited to 'Lib/test/test_uu.py')
-rw-r--r-- | Lib/test/test_uu.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Lib/test/test_uu.py b/Lib/test/test_uu.py index cbf6724..25fffbf 100644 --- a/Lib/test/test_uu.py +++ b/Lib/test/test_uu.py @@ -93,6 +93,28 @@ class UUTest(unittest.TestCase): except uu.Error as e: self.assertEqual(str(e), "No valid begin line found in input file") + def test_garbage_padding(self): + # Issue #22406 + encodedtext = ( + b"begin 644 file\n" + # length 1; bits 001100 111111 111111 111111 + b"\x21\x2C\x5F\x5F\x5F\n" + b"\x20\n" + b"end\n" + ) + plaintext = b"\x33" # 00110011 + + with self.subTest("uu.decode()"): + inp = io.BytesIO(encodedtext) + out = io.BytesIO() + uu.decode(inp, out, quiet=True) + self.assertEqual(out.getvalue(), plaintext) + + with self.subTest("uu_codec"): + import codecs + decoded = codecs.decode(encodedtext, "uu_codec") + self.assertEqual(decoded, plaintext) + class UUStdIOTest(unittest.TestCase): def setUp(self): |