mirror of
https://github.com/python/cpython.git
synced 2025-12-15 21:44:50 +00:00
Removed implicit convertions of str object to bytes from base64.
This also exposed some bugs in urlib2 and email.base64mime, which I tried my best to fix. However, someone will probably have to double check.
This commit is contained in:
parent
8cb02b6000
commit
5209857f8e
4 changed files with 42 additions and 16 deletions
|
|
@ -66,9 +66,10 @@ def header_encode(header_bytes, charset='iso-8859-1'):
|
|||
charset names the character set to use to encode the header. It defaults
|
||||
to iso-8859-1. Base64 encoding is defined in RFC 2045.
|
||||
"""
|
||||
# Return empty headers unchanged
|
||||
if not header_bytes:
|
||||
return str(header_bytes)
|
||||
return ""
|
||||
if isinstance(header_bytes, str):
|
||||
header_bytes = header_bytes.encode(charset)
|
||||
encoded = b64encode(header_bytes).decode("ascii")
|
||||
return '=?%s?b?%s?=' % (charset, encoded)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue