[CalendarServer-changes] [7893] CalendarServer/branches/users/glyph/imip-and-admin-html/ twistedcaldav
source_changes at macosforge.org
source_changes at macosforge.org
Thu Aug 11 21:38:49 PDT 2011
Revision: 7893
http://trac.macosforge.org/projects/calendarserver/changeset/7893
Author: glyph at apple.com
Date: 2011-08-11 21:38:49 -0700 (Thu, 11 Aug 2011)
Log Message:
-----------
tighten up unicode type correctness a little
Modified Paths:
--------------
CalendarServer/branches/users/glyph/imip-and-admin-html/twistedcaldav/mail.py
CalendarServer/branches/users/glyph/imip-and-admin-html/twistedcaldav/test/test_mail.py
Modified: CalendarServer/branches/users/glyph/imip-and-admin-html/twistedcaldav/mail.py
===================================================================
--- CalendarServer/branches/users/glyph/imip-and-admin-html/twistedcaldav/mail.py 2011-08-12 04:38:38 UTC (rev 7892)
+++ CalendarServer/branches/users/glyph/imip-and-admin-html/twistedcaldav/mail.py 2011-08-12 04:38:49 UTC (rev 7893)
@@ -1215,6 +1215,8 @@
@param orgCN: Common name / display name for the organizer.
+ @type orgCN: C{unicode}
+
@param attendees: A C{list} of 2-C{tuple}s of (common name, email
address) similar to (orgEmail, orgCN).
@@ -1270,14 +1272,14 @@
msg.attach(msgAlt)
# plain version
- msgPlain = MIMEText(plainText.encode("UTF-8"), "plain", "UTF-8")
+ msgPlain = MIMEText(plainText, "plain", "UTF-8")
msgAlt.attach(msgPlain)
# html version
msgHtmlRelated = MIMEMultipart("related", type="text/html")
msgAlt.attach(msgHtmlRelated)
- msgHtml = MIMEText(htmlText.encode("UTF-8"), "html", "UTF-8")
+ msgHtml = MIMEText(htmlText, "html", "UTF-8")
msgHtmlRelated.attach(msgHtml)
# an image for html version
Modified: CalendarServer/branches/users/glyph/imip-and-admin-html/twistedcaldav/test/test_mail.py
===================================================================
--- CalendarServer/branches/users/glyph/imip-and-admin-html/twistedcaldav/test/test_mail.py 2011-08-12 04:38:38 UTC (rev 7892)
+++ CalendarServer/branches/users/glyph/imip-and-admin-html/twistedcaldav/test/test_mail.py 2011-08-12 04:38:49 UTC (rev 7893)
@@ -494,10 +494,10 @@
msgID, msgTxt = self.handler.generateEmail(
inviteState='new',
calendar=calendar,
- orgEmail="user01 at localhost",
- orgCN="User Zero One",
- attendees=[("User 1", "user01 at localhost"),
- ("User 2", "user02 at localhost")],
+ orgEmail=u"user01 at localhost",
+ orgCN=u"User Z\xe9ro One",
+ attendees=[(u"Us\xe9r One", "user01 at localhost"),
+ (u"User 2", "user02 at localhost")],
fromAddress="user01 at localhost",
replyToAddress="imip-system at localhost",
toAddress="user03 at localhost",
@@ -521,6 +521,26 @@
self.assertEquals(actualTypes, expectedTypes)
+ def test_emailEncoding(self):
+ """
+ L{MailHandler.generateEmail} will preserve any non-ASCII characters
+ present in the fields that it formats in the message body.
+ """
+ msgID, message = self.generateSampleEmail()
+ textPart = partByType(message, "text/plain")
+ htmlPart = partByType(message, "text/html")
+
+ plainText = textPart.get_payload(decode=True).decode(
+ textPart.get_content_charset()
+ )
+ htmlText = htmlPart.get_payload(decode=True).decode(
+ htmlPart.get_content_charset()
+ )
+
+ self.assertIn(u"Us\u00e9r One", plainText)
+ self.assertIn(u"Us\u00e9r One", htmlText)
+
+
def test_emailQuoting(self):
"""
L{MailHandler.generateEmail} will HTML-quote all relevant fields in the
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110811/c88a4793/attachment.html>
More information about the calendarserver-changes
mailing list