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
1e949890
Commit
1e949890
authored
Feb 07, 2014
by
R David Murray
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#17369: Improve handling of broken RFC2231 values in get_filename.
This fixes a regression relative to python2.
parent
bd3a11ba
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
0 deletions
+28
-0
Lib/email/utils.py
Lib/email/utils.py
+4
-0
Lib/test/test_email/test_email.py
Lib/test/test_email/test_email.py
+20
-0
Misc/NEWS
Misc/NEWS
+4
-0
No files found.
Lib/email/utils.py
View file @
1e949890
...
@@ -337,6 +337,10 @@ def collapse_rfc2231_value(value, errors='replace',
...
@@ -337,6 +337,10 @@ def collapse_rfc2231_value(value, errors='replace',
# object. We do not want bytes() normal utf-8 decoder, we want a straight
# object. We do not want bytes() normal utf-8 decoder, we want a straight
# interpretation of the string as character bytes.
# interpretation of the string as character bytes.
charset
,
language
,
text
=
value
charset
,
language
,
text
=
value
if
charset
is
None
:
# Issue 17369: if charset/lang is None, decode_rfc2231 couldn't parse
# the value, so use the fallback_charset.
charset
=
fallback_charset
rawbytes
=
bytes
(
text
,
'raw-unicode-escape'
)
rawbytes
=
bytes
(
text
,
'raw-unicode-escape'
)
try
:
try
:
return
str
(
rawbytes
,
charset
,
errors
)
return
str
(
rawbytes
,
charset
,
errors
)
...
...
Lib/test/test_email/test_email.py
View file @
1e949890
...
@@ -5018,6 +5018,26 @@ Content-Type: application/x-foo; name*0=\"Frank's\"; name*1=\" Document\"
...
@@ -5018,6 +5018,26 @@ Content-Type: application/x-foo; name*0=\"Frank's\"; name*1=\" Document\"
self
.
assertNotIsInstance
(
param
,
tuple
)
self
.
assertNotIsInstance
(
param
,
tuple
)
self
.
assertEqual
(
param
,
"Frank's Document"
)
self
.
assertEqual
(
param
,
"Frank's Document"
)
def
test_rfc2231_missing_tick
(
self
):
m
=
'''
\
Content-Disposition: inline;
\
t
filename*0*="'This%20is%20broken";
'''
msg
=
email
.
message_from_string
(
m
)
self
.
assertEqual
(
msg
.
get_filename
(),
"'This is broken"
)
def
test_rfc2231_missing_tick_with_encoded_non_ascii
(
self
):
m
=
'''
\
Content-Disposition: inline;
\
t
filename*0*="'This%20is%E2broken";
'''
msg
=
email
.
message_from_string
(
m
)
self
.
assertEqual
(
msg
.
get_filename
(),
"'This is
\
ufffd
broken"
)
# test_headerregistry.TestContentTypeHeader.rfc2231_single_quote_in_value_with_charset_and_lang
# test_headerregistry.TestContentTypeHeader.rfc2231_single_quote_in_value_with_charset_and_lang
def
test_rfc2231_tick_attack_extended
(
self
):
def
test_rfc2231_tick_attack_extended
(
self
):
eq
=
self
.
assertEqual
eq
=
self
.
assertEqual
...
...
Misc/NEWS
View file @
1e949890
...
@@ -45,6 +45,10 @@ Core and Builtins
...
@@ -45,6 +45,10 @@ Core and Builtins
Library
Library
-------
-------
-
Issue
#
17369
:
get_filename
was
raising
an
exception
if
the
filename
parameter
's RFC2231 encoding was broken in certain ways. This was
a regression relative to python2.
- Issue #20013: Some imap servers disconnect if the current mailbox is
- Issue #20013: Some imap servers disconnect if the current mailbox is
deleted, and imaplib did not handle that case gracefully. Now it
deleted, and imaplib did not handle that case gracefully. Now it
handles the '
bye
' correctly.
handles the '
bye
' correctly.
...
...
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