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
930181c5
Commit
930181c5
authored
Jul 22, 2012
by
Senthil Kumaran
Browse files
Options
Browse Files
Download
Plain Diff
merge heads.
parents
1b9c6274
00f79843
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
2 deletions
+35
-2
Lib/email/generator.py
Lib/email/generator.py
+10
-2
Lib/test/test_email/test_email.py
Lib/test/test_email/test_email.py
+22
-0
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/email/generator.py
View file @
930181c5
...
@@ -252,7 +252,11 @@ class Generator:
...
@@ -252,7 +252,11 @@ class Generator:
msg
.
set_boundary
(
boundary
)
msg
.
set_boundary
(
boundary
)
# If there's a preamble, write it out, with a trailing CRLF
# If there's a preamble, write it out, with a trailing CRLF
if
msg
.
preamble
is
not
None
:
if
msg
.
preamble
is
not
None
:
self
.
write
(
msg
.
preamble
+
self
.
_NL
)
if
self
.
_mangle_from_
:
preamble
=
fcre
.
sub
(
'>From '
,
msg
.
preamble
)
else
:
preamble
=
msg
.
preamble
self
.
write
(
preamble
+
self
.
_NL
)
# dash-boundary transport-padding CRLF
# dash-boundary transport-padding CRLF
self
.
write
(
'--'
+
boundary
+
self
.
_NL
)
self
.
write
(
'--'
+
boundary
+
self
.
_NL
)
# body-part
# body-part
...
@@ -270,7 +274,11 @@ class Generator:
...
@@ -270,7 +274,11 @@ class Generator:
self
.
write
(
self
.
_NL
+
'--'
+
boundary
+
'--'
)
self
.
write
(
self
.
_NL
+
'--'
+
boundary
+
'--'
)
if
msg
.
epilogue
is
not
None
:
if
msg
.
epilogue
is
not
None
:
self
.
write
(
self
.
_NL
)
self
.
write
(
self
.
_NL
)
self
.
write
(
msg
.
epilogue
)
if
self
.
_mangle_from_
:
epilogue
=
fcre
.
sub
(
'>From '
,
msg
.
epilogue
)
else
:
epilogue
=
msg
.
epilogue
self
.
write
(
epilogue
)
def
_handle_multipart_signed
(
self
,
msg
):
def
_handle_multipart_signed
(
self
,
msg
):
# The contents of signed parts has to stay unmodified in order to keep
# The contents of signed parts has to stay unmodified in order to keep
...
...
Lib/test/test_email/test_email.py
View file @
930181c5
...
@@ -1283,6 +1283,28 @@ From the desk of A.A.A.:
...
@@ -1283,6 +1283,28 @@ From the desk of A.A.A.:
Blah blah blah
Blah blah blah
"""
)
"""
)
def
test_mangle_from_in_preamble_and_epilog
(
self
):
s
=
StringIO
()
g
=
Generator
(
s
,
mangle_from_
=
True
)
msg
=
email
.
message_from_string
(
textwrap
.
dedent
(
"""
\
From: foo@bar.com
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary=XXX
From somewhere unknown
--XXX
Content-Type: text/plain
foo
--XXX--
From somewhere unknowable
"""
))
g
.
flatten
(
msg
)
self
.
assertEqual
(
len
([
1
for
x
in
s
.
getvalue
().
split
(
'
\
n
'
)
if
x
.
startswith
(
'>From '
)]),
2
)
# Test the basic MIMEAudio class
# Test the basic MIMEAudio class
...
...
Misc/NEWS
View file @
930181c5
...
@@ -52,6 +52,9 @@ Core and Builtins
...
@@ -52,6 +52,9 @@ Core and Builtins
Library
Library
-------
-------
-
Issue
#
15232
:
when
mangle_from
is
True
,
email
.
Generator
now
correctly
mangles
lines
that
start
with
'From'
that
occur
in
a
MIME
preamble
or
epilogue
.
-
Issue
#
15094
:
Incorrectly
placed
#
endif
in
_tkinter
.
c
.
-
Issue
#
15094
:
Incorrectly
placed
#
endif
in
_tkinter
.
c
.
Patch
by
Serhiy
Storchaka
.
Patch
by
Serhiy
Storchaka
.
...
...
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