Commit fde9829a authored by Yusei Tahara's avatar Yusei Tahara

Remove newline at the end of mail body.

Encode subject header.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@21200 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent a632ea60
...@@ -15,6 +15,8 @@ try: ...@@ -15,6 +15,8 @@ try:
except ImportError: except ImportError:
BaseMailTemplate = None BaseMailTemplate = None
from email.Header import make_header
if BaseMailTemplate is not None: if BaseMailTemplate is not None:
def _process_utf8(self,kw): def _process_utf8(self,kw):
# sort out what encoding we're going to use # sort out what encoding we're going to use
...@@ -22,6 +24,10 @@ if BaseMailTemplate is not None: ...@@ -22,6 +24,10 @@ if BaseMailTemplate is not None:
self.getProperty('encoding', self.getProperty('encoding',
BaseMailTemplate.default_encoding)) BaseMailTemplate.default_encoding))
text = self.__class__.__bases__[1].__call__(self,**kw) text = self.__class__.__bases__[1].__call__(self,**kw)
# ZPT adds newline at the end, but it breaks backward compatibility.
# So I remove it.
if text and text[-1]=='\n':
text = text[:-1]
if not self.html() and isinstance(text, unicode): if not self.html() and isinstance(text, unicode):
text = text.encode(encoding,'replace') text = text.encode(encoding,'replace')
# now turn the result into a MIMEText object # now turn the result into a MIMEText object
...@@ -59,6 +65,8 @@ if BaseMailTemplate is not None: ...@@ -59,6 +65,8 @@ if BaseMailTemplate is not None:
# make sure we have no unicode headers # make sure we have no unicode headers
if isinstance(value,unicode): if isinstance(value,unicode):
value = value.encode(encoding) value = value.encode(encoding)
if key=='subject':
value = make_header([(value, 'utf-8')]).encode()
headers[header]=value headers[header]=value
# check required values have been supplied # check required values have been supplied
errors = [] errors = []
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment