[CalendarServer-changes] [14962] CalendarServer/trunk/txdav/caldav/datastore/scheduling/imip
source_changes at macosforge.org
source_changes at macosforge.org
Tue Jul 14 13:58:41 PDT 2015
Revision: 14962
http://trac.calendarserver.org//changeset/14962
Author: cdaboo at apple.com
Date: 2015-07-14 13:58:41 -0700 (Tue, 14 Jul 2015)
Log Message:
-----------
Fix iMIP send failures when organizer CN is missing or contains non-ascii characters.
Modified Paths:
--------------
CalendarServer/trunk/txdav/caldav/datastore/scheduling/imip/outbound.py
CalendarServer/trunk/txdav/caldav/datastore/scheduling/imip/test/test_outbound.py
Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/imip/outbound.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/imip/outbound.py 2015-07-13 21:16:34 UTC (rev 14961)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/imip/outbound.py 2015-07-14 20:58:41 UTC (rev 14962)
@@ -453,6 +453,8 @@
orgEmail = organizerMailto[7:]
orgCN = calendar.getOrganizerProperty().parameterValue('CN', None)
+ if orgCN:
+ orgCN = orgCN.decode("utf-8")
addressWithToken = formattedFrom
# At the point we've created the token in the db, which we always
@@ -663,8 +665,9 @@
# template stuff, and once again, it's just a 'mailto:'.
# tags.a(href="mailto:"+email)[cn]
if orgEmail:
- details['htmlOrganizer'] = tags.a(href="mailto:%s" % (orgEmail,))(
- orgCN)
+ if not orgCN:
+ orgCN = orgEmail
+ details['htmlOrganizer'] = tags.a(href="mailto:%s" % (orgEmail,))(orgCN)
else:
details['htmlOrganizer'] = orgCN
Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/imip/test/test_outbound.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/imip/test/test_outbound.py 2015-07-13 21:16:34 UTC (rev 14961)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/imip/test/test_outbound.py 2015-07-14 20:58:41 UTC (rev 14962)
@@ -60,7 +60,7 @@
DESCRIPTION:awesome description with "<" and "&"
END:VEVENT
END:VCALENDAR
-"""
+""".encode("utf-8")
inviteTextNoTimezone = u"""BEGIN:VCALENDAR
VERSION:2.0
@@ -83,7 +83,7 @@
DESCRIPTION:awesome description with "<" and "&"
END:VEVENT
END:VCALENDAR
-"""
+""".encode("utf-8")
inviteTextWithTimezone = u"""BEGIN:VCALENDAR
VERSION:2.0
@@ -249,7 +249,7 @@
DESCRIPTION:awesome description with "<" and "&"
END:VEVENT
END:VCALENDAR
-"""
+""".encode("utf-8")
ORGANIZER = "urn:uuid:C3B38B00-4166-11DD-B22C-A07C87E02F6A"
ATTENDEE = "mailto:attendee at example.com"
@@ -400,63 +400,63 @@
# Update
(
- """BEGIN:VCALENDAR
+ u"""BEGIN:VCALENDAR
VERSION:2.0
METHOD:REQUEST
BEGIN:VEVENT
UID:CFDD5E46-4F74-478A-9311-B3FF905449C3
DTSTART:20100325T154500Z
DTEND:20100325T164500Z
-ATTENDEE;CN=The Attendee;CUTYPE=INDIVIDUAL;PARTSTAT=NEEDS-ACTION;RSVP=TRUE:
+ATTENDEE;CN=Th\xe9 Attendee;CUTYPE=INDIVIDUAL;PARTSTAT=NEEDS-ACTION;RSVP=TRUE:
mailto:attendee at example.com
-ATTENDEE;CN=The Organizer;CUTYPE=INDIVIDUAL;EMAIL=organizer at example.com;PAR
+ATTENDEE;CN=Th\xe9 Organizer;CUTYPE=INDIVIDUAL;EMAIL=organizer at example.com;PAR
TSTAT=ACCEPTED:urn:uuid:C3B38B00-4166-11DD-B22C-A07C87E02F6A
-ORGANIZER;CN=The Organizer;EMAIL=organizer at example.com:urn:uuid:C3B38B00-41
+ORGANIZER;CN=Th\xe9 Organizer;EMAIL=organizer at example.com:urn:uuid:C3B38B00-41
66-11DD-B22C-A07C87E02F6A
-SUMMARY:testing outbound( ) *update*
+SUMMARY:t\xe9sting outbound( ) *update*
END:VEVENT
END:VCALENDAR
-""",
+""".encode("utf-8"),
"CFDD5E46-4F74-478A-9311-B3FF905449C3",
"urn:uuid:C3B38B00-4166-11DD-B22C-A07C87E02F6A",
"mailto:attendee at example.com",
"update",
"organizer at example.com",
- "The Organizer",
+ u"Th\xe9 Organizer",
[
- (u'The Attendee', u'attendee at example.com'),
- (u'The Organizer', u'organizer at example.com')
+ (u'Th\xe9 Attendee', u'attendee at example.com'),
+ (u'Th\xe9 Organizer', u'organizer at example.com')
],
- "The Organizer <organizer at example.com>",
- "The Organizer <organizer at example.com>",
+ u"Th\xe9 Organizer <organizer at example.com>",
+ "=?utf-8?q?Th=C3=A9_Organizer_=3Corganizer=40example=2Ecom=3E?=",
"attendee at example.com",
),
# Reply
(
- """BEGIN:VCALENDAR
+ u"""BEGIN:VCALENDAR
VERSION:2.0
METHOD:REPLY
BEGIN:VEVENT
UID:DFDD5E46-4F74-478A-9311-B3FF905449C4
DTSTART:20100325T154500Z
DTEND:20100325T164500Z
-ATTENDEE;CN=The Attendee;CUTYPE=INDIVIDUAL;EMAIL=attendee at example.com;PARTST
+ATTENDEE;CN=Th\xe9 Attendee;CUTYPE=INDIVIDUAL;EMAIL=attendee at example.com;PARTST
AT=ACCEPTED:urn:uuid:C3B38B00-4166-11DD-B22C-A07C87E02F6A
-ORGANIZER;CN=The Organizer;EMAIL=organizer at example.com:mailto:organizer at exam
+ORGANIZER;CN=Th\xe9 Organizer;EMAIL=organizer at example.com:mailto:organizer at exam
ple.com
-SUMMARY:testing outbound( ) *reply*
+SUMMARY:t\xe9sting outbound( ) *reply*
END:VEVENT
END:VCALENDAR
-""",
+""".encode("utf-8"),
None,
"urn:uuid:C3B38B00-4166-11DD-B22C-A07C87E02F6A",
"mailto:organizer at example.com",
"reply",
"organizer at example.com",
- "The Organizer",
+ u"Th\xe9 Organizer",
[
- (u'The Attendee', u'attendee at example.com'),
+ (u'Th\xe9 Attendee', u'attendee at example.com'),
],
"attendee at example.com",
"attendee at example.com",
@@ -635,6 +635,48 @@
self.assertEquals(actualTypes, expectedTypes)
+ def test_generateEmail_noOrganizerCN(self):
+ """
+ L{MailHandler.generateEmail} generates a MIME-formatted email when
+ the organizer property has no CN parameter.
+ """
+ calendar = Component.fromString(initialInviteText)
+ _ignore_msgID, msgTxt = self.sender.generateEmail(
+ inviteState='new',
+ calendar=calendar,
+ orgEmail=u"user01 at localhost",
+ orgCN=None,
+ 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",
+ )
+ message = email.message_from_string(msgTxt)
+ self.assertTrue(message is not None)
+
+
+ def test_generateEmail_noAttendeeCN(self):
+ """
+ L{MailHandler.generateEmail} generates a MIME-formatted email when
+ the attendee property has no CN parameter.
+ """
+ calendar = Component.fromString(initialInviteText)
+ _ignore_msgID, msgTxt = self.sender.generateEmail(
+ inviteState='new',
+ calendar=calendar,
+ orgEmail=u"user01 at localhost",
+ orgCN=u"User Z\xe9ro One",
+ attendees=[(None, "user01 at localhost"),
+ (None, "user02 at localhost")],
+ fromAddress="user01 at localhost",
+ replyToAddress="imip-system at localhost",
+ toAddress="user03 at localhost",
+ )
+ message = email.message_from_string(msgTxt)
+ self.assertTrue(message is not None)
+
+
def test_messageID(self):
"""
L{SMTPSender.betterMessageID} generates a Message-ID domain matching
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20150714/66b7518c/attachment.html>
More information about the calendarserver-changes
mailing list