Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
6bdb1769
Commit
6bdb1769
authored
Jun 18, 2011
by
R David Murray
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#11584: make decode_header handle Header objects correctly
This updates b21fdfa0019c, which fixed this bug incorrectly.
parent
c88bce15
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
4 deletions
+8
-4
Lib/email/header.py
Lib/email/header.py
+3
-2
Lib/email/test/test_email.py
Lib/email/test/test_email.py
+2
-2
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/email/header.py
View file @
6bdb1769
...
...
@@ -73,9 +73,10 @@ def decode_header(header):
An email.errors.HeaderParseError may be raised when certain decoding error
occurs (e.g. a base64 decoding exception).
"""
# If it is a Header object, we can just return the chunks.
# If it is a Header object, we can just return the
encoded
chunks.
if
hasattr
(
header
,
'_chunks'
):
return
list
(
header
.
_chunks
)
return
[(
_charset
.
_encode
(
string
,
str
(
charset
)),
str
(
charset
))
for
string
,
charset
in
header
.
_chunks
]
# If no encoding, just return the header with no charset.
if
not
ecre
.
search
(
header
):
return
[(
header
,
None
)]
...
...
Lib/email/test/test_email.py
View file @
6bdb1769
...
...
@@ -4176,8 +4176,8 @@ A very long line that must get split to something other than at the
def
test_escaped_8bit_header
(
self
):
x
=
b'Ynwp4dUEbay Auction Semiar- No Charge
\
x96
Earn Big'
x
=
x
.
decode
(
'ascii'
,
'surrogateescape'
)
h
=
Header
(
x
,
charset
=
email
.
charset
.
UNKNOWN8BIT
)
e
=
x
.
decode
(
'ascii'
,
'surrogateescape'
)
h
=
Header
(
e
,
charset
=
email
.
charset
.
UNKNOWN8BIT
)
self
.
assertEqual
(
str
(
h
),
'Ynwp4dUEbay Auction Semiar- No Charge
\
uFFFD
Earn Big'
)
self
.
assertEqual
(
email
.
header
.
decode_header
(
h
),
[(
x
,
'unknown-8bit'
)])
...
...
Misc/NEWS
View file @
6bdb1769
...
...
@@ -25,6 +25,9 @@ Core and Builtins
Library
-------
- Issue #11584: email.header.decode_header no longer fails if the header
passed to it is a Header object.
- Issue #11700: mailbox proxy object close methods can now be called multiple
times without error.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment