Skip to content
Permalink
Browse files

Repair certain inbound third-party IMIP mistakes so we can continue t…

…o process them.

git-svn-id: https://svn.calendarserver.org/repository/calendarserver/CalendarServer/trunk@14993 e27351fd-9f3e-4f54-a53b-843176b1656c
  • Loading branch information...
m0rgen committed Jul 24, 2015
1 parent 99ca95e commit 58cd6e675f27317a4c6b13918bad3bb2f8bc4b69
@@ -188,6 +188,30 @@ def scheduleNextMailPoll(store, seconds):



def sanitizeCalendar(calendar):
"""
Clean up specific issues seen in the wild from third party IMIP capable
servers.
@param calendar: the calendar Component to sanitize
@type calendar: L{Component}
"""
# Don't let a missing PRODID prevent the reply from being processed
if not calendar.hasProperty("PRODID"):
calendar.addProperty(
Property(
"PRODID", "Unknown"
)
)

# For METHOD:REPLY we can remove STATUS properties
methodProperty = calendar.getProperty("METHOD")
if methodProperty is not None:
if methodProperty.value() == "REPLY":
calendar.removeAllPropertiesWithName("STATUS")



class MailReceiver(object):

NO_TOKEN = 0
@@ -400,13 +424,7 @@ def processReply(self, msg):
calendar = Component.fromString(calBody)
event = calendar.mainComponent()

# Don't let a missing PRODID prevent the reply from being processed
if not calendar.hasProperty("PRODID"):
calendar.addProperty(
Property(
"PRODID", "Unknown"
)
)
sanitizeCalendar(calendar)

calendar.removeAllButOneAttendee(record.attendee)
organizerProperty = calendar.getOrganizerProperty()
@@ -29,6 +29,7 @@
from txdav.caldav.datastore.scheduling.imip.inbound import injectMessage
from txdav.caldav.datastore.scheduling.imip.inbound import shouldDeleteAllMail
from txdav.caldav.datastore.scheduling.imip.inbound import IMAP4DownloadProtocol
from txdav.caldav.datastore.scheduling.imip.inbound import sanitizeCalendar
from txdav.common.datastore.test.util import CommonCommonTests

from twext.enterprise.jobqueue import JobItem
@@ -484,6 +485,34 @@ def values(self):
self.assertTrue(result is None)


def test_sanitizeCalendar(self):
"""
Verify certain inbound third party mistakes are corrected.
"""

data = """BEGIN:VCALENDAR
VERSION:2.0
METHOD:REPLY
BEGIN:VEVENT
UID:12345-67890
DTSTAMP:20130208T120000Z
DTSTART:20180601T120000Z
DTEND:20180601T130000Z
ORGANIZER:urn:x-uid:user01
ATTENDEE:mailto:xyzzy@example.com;PARTSTAT=ACCEPTED
STATUS:ACCEPTED
STATUS:ACCEPTED
END:VEVENT
END:VCALENDAR
"""
calendar = Component.fromString(data)
sanitizeCalendar(calendar)
self.assertTrue(calendar.hasProperty("PRODID"))
self.assertFalse(calendar.hasProperty("STATUS"))





class StubFactory(object):

0 comments on commit 58cd6e6

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