bpo-38945: UU Encoding: Don't let newline in filename corrupt the output format (#17418)

This commit is contained in:
Matthew Rollings 2019-12-02 22:25:21 +00:00 committed by Guido van Rossum
parent 016b0280b8
commit a62ad4730c
4 changed files with 21 additions and 0 deletions

View file

@ -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)