You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
uu codec decoder treats any line starting with "begin" as the header #161092
The uu codec's decoder takes the first line whose first five bytes are begin as the uuencode header, without checking that an octal mode follows. A line of leading text such as "beginning of the report", a bare begin or a begin-base64 header therefore starts the data, so the codec either decodes the wrong block or raises binascii.Error on well-formed input.
importcodecs, emailtext=b"beginning of the report\n#0V%T\n\nend\nbegin 666 pet.txt\n#9&]G\n\nend\n"print(codecs.decode(text, "uu")) # b'Cat'msg=email.message_from_bytes(b"Content-Transfer-Encoding: x-uuencode\n\n"+text)
print(msg.get_payload(decode=True)) # b'dog'codecs.decode(b"beginning with version 2\n"+codecs.encode(b"hello", "uu"), "uu")
# binascii.Error: Illegal char
Expected b'dog' from both, as email.message._decode_uu() and the removed uu.decode() skip lines that are not begin <octal mode>. The prefix test came over unchanged from Python 2 when the codec was restored in 3.2.
Activity
gh-161092: Require an octal mode in the uu codec "begin" line (GH-161093