summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/unit/test-011-wallace_resources.py9
-rw-r--r--wallace/module_resources.py15
2 files changed, 17 insertions, 7 deletions
diff --git a/tests/unit/test-011-wallace_resources.py b/tests/unit/test-011-wallace_resources.py
index 204df06..50fdc6b 100644
--- a/tests/unit/test-011-wallace_resources.py
+++ b/tests/unit/test-011-wallace_resources.py
@@ -305,6 +305,15 @@ class TestWallaceResources(unittest.TestCase):
itips5 = module_resources.itip_events_from_message(message_from_string(itip_empty))
self.assertEqual(len(itips5), 0, "Simple plain text message")
+ # invalid itip blocks
+ self.assertRaises(Exception, module_resources.itip_events_from_message, message_from_string(itip_multipart.replace("BEGIN:VEVENT", "")))
+
+ itips6 = module_resources.itip_events_from_message(message_from_string(itip_multipart.replace("DTSTART;", "X-DTSTART;")))
+ self.assertEqual(len(itips6), 0, "Event with not DTSTART")
+
+ itips7 = module_resources.itip_events_from_message(message_from_string(itip_non_multipart.replace("METHOD:REQUEST", "METHOD:PUBLISH").replace("method=REQUEST", "method=PUBLISH")))
+ self.assertEqual(len(itips7), 0, "Invalid METHOD")
+
def test_002_resource_record_from_email_address(self):
res = module_resources.resource_record_from_email_address("doe@example.org")
diff --git a/wallace/module_resources.py b/wallace/module_resources.py
index cf03520..3db2209 100644
--- a/wallace/module_resources.py
+++ b/wallace/module_resources.py
@@ -152,7 +152,11 @@ def execute(*args, **kw):
# An iTip message may contain multiple events. Later on, test if the message
# is an iTip message by checking the length of this list.
- itip_events = itip_events_from_message(message)
+ try:
+ itip_events = itip_events_from_message(message)
+ except Exception, e:
+ log.error(_("Failed to parse iTip events from message: %r" % (e)))
+ itip_events = []
if not len(itip_events) > 0:
log.info(
@@ -586,7 +590,7 @@ def itip_events_from_message(message):
seen_uids = []
# iTip methods we are actually interested in. Other methods will be ignored.
- itip_methods = [ "REQUEST", "REPLY", "ADD", "CANCEL" ]
+ itip_methods = [ "REQUEST", "CANCEL" ]
# Are all iTip messages multipart? No! RFC 6047, section 2.4 states "A
# MIME body part containing content information that conforms to this
@@ -600,11 +604,8 @@ def itip_events_from_message(message):
# But in real word, other mime-types are used as well
if part.get_content_type() in [ "text/calendar", "text/x-vcalendar", "application/ics" ]:
if not str(part.get_param('method')).upper() in itip_methods:
- log.error(
- _("Method %r not really interesting for us.") % (
- part.get_param('method')
- )
- )
+ log.error(_("Method %r not really interesting for us.") % (part.get_param('method')))
+ continue
# Get the itip_payload
itip_payload = part.get_payload(decode=True)