summaryrefslogtreecommitdiffstats
path: root/Lib/encodings
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-12-02 22:44:44 (GMT)
committerGitHub <noreply@github.com>2019-12-02 22:44:44 (GMT)
commit8859fc629474ab1ca7eb2e67aec538097c327e58 (patch)
treeb755ac1d3671368753557afa3a0b47ec833cab68 /Lib/encodings
parent9e728806d03fff8fa9e75159e567b2b4e040971b (diff)
downloadcpython-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/encodings')
-rw-r--r--Lib/encodings/uu_codec.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/encodings/uu_codec.py b/Lib/encodings/uu_codec.py
index 2a5728f..4e58c62 100644
--- a/Lib/encodings/uu_codec.py
+++ b/Lib/encodings/uu_codec.py
@@ -20,6 +20,10 @@ def uu_encode(input, errors='strict', filename='<data>', mode=0o666):
read = infile.read
write = outfile.write
+ # Remove newline chars from filename
+ filename = filename.replace('\n','\\n')
+ filename = filename.replace('\r','\\r')
+
# Encode
write(('begin %o %s\n' % (mode & 0o777, filename)).encode('ascii'))
chunk = read(45)