summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_uu.py
diff options
context:
space:
mode:
authorMatthew Rollings <1211162+stealthcopter@users.noreply.github.com>2019-12-02 22:25:21 (GMT)
committerGuido van Rossum <guido@python.org>2019-12-02 22:25:21 (GMT)
commita62ad4730c9b575f140f24074656c0257c86a09a (patch)
tree2fe5664ba3d3bf745bda95c2539e4c25e3535380 /Lib/test/test_uu.py
parent016b0280b8a97bc26e97c6a8dd5fb8fad5fe72e4 (diff)
downloadcpython-a62ad4730c9b575f140f24074656c0257c86a09a.zip
cpython-a62ad4730c9b575f140f24074656c0257c86a09a.tar.gz
cpython-a62ad4730c9b575f140f24074656c0257c86a09a.tar.bz2
bpo-38945: UU Encoding: Don't let newline in filename corrupt the output format (#17418)
Diffstat (limited to 'Lib/test/test_uu.py')
-rw-r--r--Lib/test/test_uu.py9
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):