Commit 6f3992d5 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

use email.utils.formataddr instead of '"%s" <%s>' to support double-quotes and...

use email.utils.formataddr instead of '"%s" <%s>' to support double-quotes and backslashes correctly.
parent 190820a8
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
############################################################################## ##############################################################################
import re, types import re, types
from email.utils import formataddr
from DateTime import DateTime from DateTime import DateTime
from AccessControl import ClassSecurityInfo, Unauthorized from AccessControl import ClassSecurityInfo, Unauthorized
from Products.ERP5Type.Accessor.Constant import PropertyGetter as ConstantGetter from Products.ERP5Type.Accessor.Constant import PropertyGetter as ConstantGetter
...@@ -646,11 +647,8 @@ class EmailDocument(TextDocument): ...@@ -646,11 +647,8 @@ class EmailDocument(TextDocument):
if from_url is None: if from_url is None:
sender = self.getSourceValue() sender = self.getSourceValue()
if sender is not None: if sender is not None:
if sender.getTitle(): from_url = formataddr((sender.getTitle(),
from_url = '"%s" <%s>' % (sender.getTitle(), sender.getDefaultEmailText()))
sender.getDefaultEmailText())
else:
from_url = sender.getDefaultEmailText()
else: else:
from_url = self.getSender() # Access sender directly from_url = self.getSender() # Access sender directly
...@@ -671,10 +669,7 @@ class EmailDocument(TextDocument): ...@@ -671,10 +669,7 @@ class EmailDocument(TextDocument):
for recipient in self.getDestinationValueList(): for recipient in self.getDestinationValueList():
email = recipient.getDefaultEmailText() email = recipient.getDefaultEmailText()
if email: if email:
if recipient.getTitle(): to_url_list.append(formataddr((recipient.getTitle(), email)))
to_url_list.append('"%s" <%s>' % (recipient.getTitle(), email))
else:
to_url_list.append(email)
else: else:
raise ValueError, 'Recipient %s has no defined email' % recipient raise ValueError, 'Recipient %s has no defined email' % recipient
if not to_url_list: if not to_url_list:
......
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