[CalendarServer-changes] [13625] CalendarServer/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Tue Jun 10 09:28:47 PDT 2014
Revision: 13625
http://trac.calendarserver.org//changeset/13625
Author: cdaboo at apple.com
Date: 2014-06-10 09:28:47 -0700 (Tue, 10 Jun 2014)
Log Message:
-----------
If TZID is not recognized by the server, reject the PUT.
Modified Paths:
--------------
CalendarServer/trunk/requirements-dev.txt
CalendarServer/trunk/twistedcaldav/ical.py
CalendarServer/trunk/twistedcaldav/storebridge.py
CalendarServer/trunk/twistedcaldav/test/test_icalendar.py
CalendarServer/trunk/txdav/caldav/datastore/sql.py
CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py
CalendarServer/trunk/txdav/caldav/icalendarstore.py
Modified: CalendarServer/trunk/requirements-dev.txt
===================================================================
--- CalendarServer/trunk/requirements-dev.txt 2014-06-10 16:26:48 UTC (rev 13624)
+++ CalendarServer/trunk/requirements-dev.txt 2014-06-10 16:28:47 UTC (rev 13625)
@@ -7,4 +7,4 @@
mockldap
q
--editable svn+http://svn.calendarserver.org/repository/calendarserver/CalDAVClientLibrary/trunk@13420#egg=CalDAVClientLibrary
---editable svn+http://svn.calendarserver.org/repository/calendarserver/CalDAVTester/trunk@13547#egg=CalDAVTester
+--editable svn+http://svn.calendarserver.org/repository/calendarserver/CalDAVTester/trunk@13624#egg=CalDAVTester
Modified: CalendarServer/trunk/twistedcaldav/ical.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/ical.py 2014-06-10 16:26:48 UTC (rev 13624)
+++ CalendarServer/trunk/twistedcaldav/ical.py 2014-06-10 16:28:47 UTC (rev 13625)
@@ -1063,11 +1063,16 @@
"""
result = set()
- for property in self.properties():
- tzid = property.parameterValue("TZID")
- if tzid is not None:
- result.add(tzid)
- break
+ if self.name() == "VCALENDAR":
+ for component in self.subcomponents():
+ if component.name() != "VTIMEZONE":
+ result.update(component.timezoneIDs())
+ else:
+ for property in self.properties():
+ tzid = property.parameterValue("TZID")
+ if tzid is not None:
+ result.add(tzid)
+ break
return result
@@ -2032,6 +2037,12 @@
"Timezone {0} is not referenced by any non-timezone component".format(timezone,)
)
+ # TZIDs without a VTIMEZONE must be available in the server's TZ database
+ missing_timezones = timezone_refs - timezones
+ for tzid in missing_timezones:
+ # Will raise TimezoneException if tzid not present in server's database
+ hasTZ(tzid)
+
# Control character check - only HTAB, CR, LF allowed for characters in the range 0x00-0x1F
s = str(self)
if len(s.translate(None, "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x0B\x0C\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F")) != len(s):
Modified: CalendarServer/trunk/twistedcaldav/storebridge.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/storebridge.py 2014-06-10 16:26:48 UTC (rev 13624)
+++ CalendarServer/trunk/twistedcaldav/storebridge.py 2014-06-10 16:28:47 UTC (rev 13625)
@@ -60,7 +60,7 @@
InvalidPerUserDataMerge,
AttendeeAllowedError, ResourceDeletedError, InvalidAttachmentOperation,
ShareeAllowedError, DuplicatePrivateCommentsError, InvalidSplit
-, AttachmentSizeTooLarge)
+, AttachmentSizeTooLarge, UnknownTimezone)
from txdav.carddav.iaddressbookstore import (
KindChangeNotAllowedError, GroupWithUnsharedAddressNotAllowedError
)
@@ -2734,6 +2734,7 @@
ShareeAllowedError: (_CommonObjectResource._storeExceptionError, (calendarserver_namespace, "sharee-privilege-needed",),),
DuplicatePrivateCommentsError: (_CommonObjectResource._storeExceptionError, (calendarserver_namespace, "no-duplicate-private-comments",),),
LockTimeout: (_CommonObjectResource._storeExceptionUnavailable, "Lock timed out.",),
+ UnknownTimezone: (_CommonObjectResource._storeExceptionError, (caldav_namespace, "valid-timezone"),),
}
StoreMoveExceptionsErrors = {
Modified: CalendarServer/trunk/twistedcaldav/test/test_icalendar.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/test_icalendar.py 2014-06-10 16:26:48 UTC (rev 13624)
+++ CalendarServer/trunk/twistedcaldav/test/test_icalendar.py 2014-06-10 16:28:47 UTC (rev 13625)
@@ -21,16 +21,17 @@
from twisted.trial.unittest import SkipTest
from twisted.internet.defer import inlineCallbacks, succeed
+from twistedcaldav.dateops import normalizeForExpand
from twistedcaldav.ical import Component, Property, InvalidICalendarDataError, \
normalizeCUAddress, normalize_iCalStr
+from twistedcaldav.ical import iCalendarProductID
from twistedcaldav.instance import InvalidOverriddenInstanceError
import twistedcaldav.test.util
+from twistedcaldav.timezones import TimezoneException
from pycalendar.datetime import DateTime
from pycalendar.timezone import Timezone
-from twistedcaldav.ical import iCalendarProductID
from pycalendar.duration import Duration
-from twistedcaldav.dateops import normalizeForExpand
from pycalendar.value import Value
@@ -654,9 +655,27 @@
self.assertEqual(end, DateTime(2004, 11, 27))
break
- # test_component_timerange.todo = "recurrence expansion should give us no end date here"
+ def test_component_timezone_validate(self):
+ """
+ CalDAV resource validation.
+ """
+ data = """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART;TZID=BOGUS:20130806T000000
+DURATION:PT1H
+DTSTAMP:20051222T210507Z
+SUMMARY:1
+END:VEVENT
+END:VCALENDAR
+"""
+ calendar = Component.fromString(data)
+ self.failUnlessRaises(TimezoneException, calendar.validCalendarForCalDAV, False)
+
def test_parse_date(self):
"""
parse_date()
Modified: CalendarServer/trunk/txdav/caldav/datastore/sql.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/sql.py 2014-06-10 16:26:48 UTC (rev 13624)
+++ CalendarServer/trunk/txdav/caldav/datastore/sql.py 2014-06-10 16:28:47 UTC (rev 13625)
@@ -56,6 +56,7 @@
from twistedcaldav.ical import Component, InvalidICalendarDataError, Property
from twistedcaldav.instance import InvalidOverriddenInstanceError
from twistedcaldav.memcacher import Memcacher
+from twistedcaldav.timezones import TimezoneException
from txdav.base.propertystore.base import PropertyName
from txdav.caldav.datastore.query.builder import buildExpression
@@ -80,7 +81,7 @@
InvalidDefaultCalendar, \
InvalidAttachmentOperation, DuplicatePrivateCommentsError, \
TimeRangeUpperLimit, TimeRangeLowerLimit, InvalidSplit, \
- AttachmentSizeTooLarge
+ AttachmentSizeTooLarge, UnknownTimezone
from txdav.caldav.icalendarstore import QuotaExceeded
from txdav.common.datastore.sql import CommonHome, CommonHomeChild, \
CommonObjectResource, ECALENDARTYPE
@@ -1891,6 +1892,10 @@
# Basic validation
+ # Possible timezone stripping
+ if config.EnableTimezonesByReference:
+ component.stripKnownTimezones()
+
# Do validation on external requests
if internal_state == ComponentUpdateState.NORMAL:
@@ -1917,10 +1922,6 @@
# Valid attendee list size check
yield self.validAttendeeListSizeCheck(component, inserting)
- # Possible timezone stripping
- if config.EnableTimezonesByReference:
- component.stripKnownTimezones()
-
# Check location/resource organizer requirement
self.validLocationResourceOrganizer(component, inserting, internal_state)
@@ -2095,12 +2096,16 @@
try:
component.validCalendarData(validateRecurrences=self._txn._migrating)
- except InvalidICalendarDataError, e:
+ except InvalidICalendarDataError as e:
raise InvalidObjectResourceError(str(e))
try:
component.validCalendarForCalDAV(methodAllowed=self.calendar().isInbox())
- except InvalidICalendarDataError, e:
+ except InvalidICalendarDataError as e:
raise InvalidComponentForStoreError(str(e))
+ except TimezoneException as e:
+ # tzid not available
+ raise UnknownTimezone(str(e))
+
try:
if self._txn._migrating:
component.validOrganizerForScheduling(doFix=True)
@@ -4043,7 +4048,7 @@
in L{CalendarObject.splitAt}).
@type rid: L{DateTime}
@param olderUID: sets the iCalendar UID to be used in the new resource created during the split.
- If L{None} a UUID is generated and used.
+ If set to L{None}, a UUID is generated and used.
@type olderUID: L{str}
"""
@@ -4065,7 +4070,7 @@
newerUID = calendar.resourceUID()
if olderUID is None:
olderUID = str(uuid.uuid4())
- olderResourceName = olderUID
+ olderResourceName = "{0}.ics".format(olderUID)
else:
olderResourceName = "{0}.ics".format(olderUID.encode("base64")[:-1].rstrip("="))
Modified: CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py 2014-06-10 16:26:48 UTC (rev 13624)
+++ CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py 2014-06-10 16:28:47 UTC (rev 13625)
@@ -35,7 +35,7 @@
from twistedcaldav import caldavxml, ical
from twistedcaldav.caldavxml import CalendarDescription
-from twistedcaldav.config import config
+from twistedcaldav.stdconfig import config
from twistedcaldav.dateops import datetimeMktime
from twistedcaldav.ical import Component, normalize_iCalStr, diff_iCalStrs
from twistedcaldav.instance import InvalidOverriddenInstanceError
@@ -61,8 +61,9 @@
CommonCommonTests
from txdav.caldav.datastore.util import _migrateCalendar, migrateHome
from txdav.caldav.icalendarstore import ComponentUpdateState, InvalidDefaultCalendar, \
- InvalidSplit
-from txdav.common.icommondatastore import NoSuchObjectResourceError
+ InvalidSplit, UnknownTimezone
+from txdav.common.icommondatastore import NoSuchObjectResourceError, \
+ InvalidComponentForStoreError
from txdav.idav import ChangeCategory
from txdav.xml.rfc2518 import GETContentLanguage, ResourceType
@@ -1977,7 +1978,46 @@
self.assertFalse(inbox.isUsedForFreeBusy())
+ @inlineCallbacks
+ def test_missingTimezone(self):
+ """
+ Make sure missing timezone causes an exception, whether or timezones by reference is on.
+ """
+ data = """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART;TZID=BOGUS:20130806T000000
+DURATION:PT1H
+DTSTAMP:20051222T210507Z
+SUMMARY:1
+END:VEVENT
+END:VCALENDAR
+"""
+ self.patch(config, "EnableTimezonesByReference", False)
+
+ yield self.homeUnderTest(name="user01", create=True)
+ calendar = yield self.calendarUnderTest(name="calendar", home="user01")
+ yield self.failUnlessFailure(
+ calendar.createCalendarObjectWithName("data1.ics", Component.fromString(data)),
+ InvalidComponentForStoreError,
+ )
+ yield self.abort()
+
+ self.patch(config, "EnableTimezonesByReference", True)
+
+ yield self.homeUnderTest(name="user01", create=True)
+ calendar = yield self.calendarUnderTest(name="calendar", home="user01")
+ yield self.failUnlessFailure(
+ calendar.createCalendarObjectWithName("data1.ics", Component.fromString(data)),
+ UnknownTimezone,
+ )
+ yield self.abort()
+
+
+
class SchedulingTests(CommonCommonTests, unittest.TestCase):
"""
CalendarObject splitting tests
@@ -2167,8 +2207,8 @@
PRODID:-//Apple Inc.//Mac OS X 10.9.1//EN
BEGIN:VEVENT
UID:561F5DBB-3F38-4B3A-986F-DD05CBAF554F
-DTSTART;TZID=America/Los_Angeles:20131211T164500
-DTEND;TZID=America/Los_Angeles:20131211T174500
+DTSTART:20131211T164500Z
+DURATION:PT1H
ATTENDEE;CN=Conference Room One;CUTYPE=ROOM;PARTSTAT=ACCEPTED;ROLE=REQ-PARTICIPAN
T;SCHEDULE-STATUS=2.0:urn:x-uid:room-addr-1
ATTENDEE;CN=User 01;CUTYPE=INDIVIDUAL;EMAIL=user01 at example.com;PARTSTAT=AC
@@ -2183,9 +2223,9 @@
END:VEVENT
BEGIN:VEVENT
UID:561F5DBB-3F38-4B3A-986F-DD05CBAF554F
-RECURRENCE-ID;TZID=America/Los_Angeles:20131214T164500
-DTSTART;TZID=America/Los_Angeles:20131214T160000
-DTEND;TZID=America/Los_Angeles:20131214T170000
+RECURRENCE-ID:20131214T164500Z
+DTSTART:20131214T160000Z
+DURATION:PT1H
ATTENDEE;CN=Conference Room Two;CUTYPE=ROOM;PARTSTAT=ACCEPTED;ROLE=REQ-PARTICIPAN
T;SCHEDULE-STATUS=2.0:urn:x-uid:room-addr-2
ATTENDEE;CN=User 01;CUTYPE=INDIVIDUAL;EMAIL=user01 at example.com;PARTSTAT=AC
@@ -2240,8 +2280,8 @@
PRODID:-//Apple Inc.//Mac OS X 10.9.1//EN
BEGIN:VEVENT
UID:561F5DBB-3F38-4B3A-986F-DD05CBAF554F
-DTSTART;TZID=America/Los_Angeles:20131211T164500
-DTEND;TZID=America/Los_Angeles:20131211T174500
+DTSTART:20131211T164500Z
+DURATION:PT1H
ATTENDEE;X-APPLE-HOSTED-STATUS=EXTERNAL:urn:x-uid:user01
ATTENDEE:mailto:someone_external at example.com
CREATED:20131211T221854Z
@@ -2293,14 +2333,14 @@
PRODID:-//Apple Inc.//Mac OS X 10.9.1//EN
BEGIN:VEVENT
UID:561F5DBB-3F38-4B3A-986F-DD05CBAF554F
-DTSTART;TZID=America/Los_Angeles:20131211T164500
+DTSTART:20131211T164500Z
DURATION:PT1H
ATTENDEE:urn:x-uid:user01
CREATED:20131211T221854Z
DTSTAMP:20131211T230632Z
ORGANIZER:urn:x-uid:user01
RRULE:FREQ=DAILY;COUNT=1
-EXDATE;TZID=America/Los_Angeles:20131211T164500
+EXDATE:20131211T164500Z
SUMMARY:external
END:VEVENT
END:VCALENDAR
Modified: CalendarServer/trunk/txdav/caldav/icalendarstore.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/icalendarstore.py 2014-06-10 16:26:48 UTC (rev 13624)
+++ CalendarServer/trunk/txdav/caldav/icalendarstore.py 2014-06-10 16:28:47 UTC (rev 13625)
@@ -857,6 +857,13 @@
+class UnknownTimezone(CommonStoreError):
+ """
+ Unknown timezone id used.
+ """
+
+
+
#
# FIXME: These may belong elsewhere.
#
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140610/f52706f3/attachment-0001.html>
More information about the calendarserver-changes
mailing list