diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2019-12-02 22:44:44 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-02 22:44:44 (GMT) |
commit | 8859fc629474ab1ca7eb2e67aec538097c327e58 (patch) | |
tree | b755ac1d3671368753557afa3a0b47ec833cab68 /Lib/test | |
parent | 9e728806d03fff8fa9e75159e567b2b4e040971b (diff) | |
download | cpython-8859fc629474ab1ca7eb2e67aec538097c327e58.zip cpython-8859fc629474ab1ca7eb2e67aec538097c327e58.tar.gz cpython-8859fc629474ab1ca7eb2e67aec538097c327e58.tar.bz2 |
bpo-38945: UU Encoding: Don't let newline in filename corrupt the output format (GH-17418)
(cherry picked from commit a62ad4730c9b575f140f24074656c0257c86a09a)
Co-authored-by: Matthew Rollings <1211162+stealthcopter@users.noreply.github.com>
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_uu.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_uu.py b/Lib/test/test_uu.py index c9f05e5..c8709f7 100644 --- a/Lib/test/test_uu.py +++ b/Lib/test/test_uu.py @@ -136,6 +136,15 @@ class UUTest(unittest.TestCase): decoded = codecs.decode(encodedtext, "uu_codec") self.assertEqual(decoded, plaintext) + def test_newlines_escaped(self): + # Test newlines are escaped with uu.encode + inp = io.BytesIO(plaintext) + out = io.BytesIO() + filename = "test.txt\n\roverflow.txt" + safefilename = b"test.txt\\n\\roverflow.txt" + uu.encode(inp, out, filename) + self.assertIn(safefilename, out.getvalue()) + class UUStdIOTest(unittest.TestCase): def setUp(self): |