Skip to content
Permalink
Browse files

Fix iMIP send failures when organizer CN is missing or contains non-a…

…scii characters.

git-svn-id: https://svn.calendarserver.org/repository/calendarserver/CalendarServer/trunk@14962 e27351fd-9f3e-4f54-a53b-843176b1656c
  • Loading branch information...
cyrusdaboo committed Jul 14, 2015
1 parent 79ad19e commit 6b2e522eea692f756bf62e94e498d99edeb0db39
@@ -453,6 +453,8 @@ def outbound(self, txn, originator, recipient, calendar, onlyAfter=None):
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 @@ def renderHTML(self, details, organizer, attendees, canceled):
# 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

@@ -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@example.com"
@@ -400,63 +400,63 @@ def test_outbound(self):

# 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@example.com
ATTENDEE;CN=The Organizer;CUTYPE=INDIVIDUAL;EMAIL=organizer@example.com;PAR
ATTENDEE;CN=Th\xe9 Organizer;CUTYPE=INDIVIDUAL;EMAIL=organizer@example.com;PAR
TSTAT=ACCEPTED:urn:uuid:C3B38B00-4166-11DD-B22C-A07C87E02F6A
ORGANIZER;CN=The Organizer;EMAIL=organizer@example.com:urn:uuid:C3B38B00-41
ORGANIZER;CN=Th\xe9 Organizer;EMAIL=organizer@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@example.com",
"update",
"organizer@example.com",
"The Organizer",
u"Th\xe9 Organizer",
[
(u'The Attendee', u'attendee@example.com'),
(u'The Organizer', u'organizer@example.com')
(u'Th\xe9 Attendee', u'attendee@example.com'),
(u'Th\xe9 Organizer', u'organizer@example.com')
],
"The Organizer <organizer@example.com>",
"The Organizer <organizer@example.com>",
u"Th\xe9 Organizer <organizer@example.com>",
"=?utf-8?q?Th=C3=A9_Organizer_=3Corganizer=40example=2Ecom=3E?=",
"attendee@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@example.com;PARTST
ATTENDEE;CN=Th\xe9 Attendee;CUTYPE=INDIVIDUAL;EMAIL=attendee@example.com;PARTST
AT=ACCEPTED:urn:uuid:C3B38B00-4166-11DD-B22C-A07C87E02F6A
ORGANIZER;CN=The Organizer;EMAIL=organizer@example.com:mailto:organizer@exam
ORGANIZER;CN=Th\xe9 Organizer;EMAIL=organizer@example.com:mailto:organizer@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@example.com",
"reply",
"organizer@example.com",
"The Organizer",
u"Th\xe9 Organizer",
[
(u'The Attendee', u'attendee@example.com'),
(u'Th\xe9 Attendee', u'attendee@example.com'),
],
"attendee@example.com",
"attendee@example.com",
@@ -635,6 +635,48 @@ def test_generateEmail(self):
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@localhost",
orgCN=None,
attendees=[(u"Us\xe9r One", "user01@localhost"),
(u"User 2", "user02@localhost")],
fromAddress="user01@localhost",
replyToAddress="imip-system@localhost",
toAddress="user03@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@localhost",
orgCN=u"User Z\xe9ro One",
attendees=[(None, "user01@localhost"),
(None, "user02@localhost")],
fromAddress="user01@localhost",
replyToAddress="imip-system@localhost",
toAddress="user03@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

0 comments on commit 6b2e522

Please sign in to comment.
You can’t perform that action at this time.