<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[12021] CalendarServer/trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.calendarserver.org//changeset/12021">12021</a></dd>
<dt>Author</dt> <dd>cdaboo@apple.com</dd>
<dt>Date</dt> <dd>2013-12-03 11:35:19 -0800 (Tue, 03 Dec 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>Rejection of PUT with duplicate private comments.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServertrunkconfcaldavdtestplist">CalendarServer/trunk/conf/caldavd-test.plist</a></li>
<li><a href="#CalendarServertrunktwistedcaldavicalpy">CalendarServer/trunk/twistedcaldav/ical.py</a></li>
<li><a href="#CalendarServertrunktwistedcaldavstdconfigpy">CalendarServer/trunk/twistedcaldav/stdconfig.py</a></li>
<li><a href="#CalendarServertrunktwistedcaldavstorebridgepy">CalendarServer/trunk/twistedcaldav/storebridge.py</a></li>
<li><a href="#CalendarServertrunktwistedcaldavtesttest_icalendarpy">CalendarServer/trunk/twistedcaldav/test/test_icalendar.py</a></li>
<li><a href="#CalendarServertrunktxdavcaldavdatastoresqlpy">CalendarServer/trunk/txdav/caldav/datastore/sql.py</a></li>
<li><a href="#CalendarServertrunktxdavcaldavicalendarstorepy">CalendarServer/trunk/txdav/caldav/icalendarstore.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServertrunkconfcaldavdtestplist"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/conf/caldavd-test.plist (12020 => 12021)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/conf/caldavd-test.plist        2013-12-03 19:33:06 UTC (rev 12020)
+++ CalendarServer/trunk/conf/caldavd-test.plist        2013-12-03 19:35:19 UTC (rev 12021)
</span><span class="lines">@@ -826,6 +826,10 @@
</span><span class="cx">     &lt;!-- Private Events --&gt;
</span><span class="cx">     &lt;key&gt;EnablePrivateEvents&lt;/key&gt;
</span><span class="cx">     &lt;true/&gt;
</span><ins>+    
+    &lt;!-- Private Comment fix off for testing --&gt;
+    &lt;key&gt;RemoveDuplicatePrivateComments&lt;/key&gt;
+    &lt;false/&gt;
</ins><span class="cx"> 
</span><span class="cx">     &lt;!-- Timezone Service --&gt;
</span><span class="cx">     &lt;key&gt;EnableTimezoneService&lt;/key&gt;
</span></span></pre></div>
<a id="CalendarServertrunktwistedcaldavicalpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twistedcaldav/ical.py (12020 => 12021)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twistedcaldav/ical.py        2013-12-03 19:33:06 UTC (rev 12020)
+++ CalendarServer/trunk/twistedcaldav/ical.py        2013-12-03 19:35:19 UTC (rev 12021)
</span><span class="lines">@@ -3418,7 +3418,33 @@
</span><span class="cx">         return False
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+    def hasDuplicatePrivateComments(self, doFix=False):
+        &quot;&quot;&quot;
+        Test and optionally remove &quot;X-CALENDARSERVER-ATTENDEE-COMMENT&quot; properties that have the same
+        &quot;X-CALENDARSERVER-ATTENDEE-REF&quot; parameter values in the same component.
</ins><span class="cx"> 
</span><ins>+        @return: C{True} if there are duplicates that were not fixed.
+        &quot;&quot;&quot;
+        if self.name() == &quot;VCALENDAR&quot;:
+            for component in self.subcomponents():
+                if component.name() in (&quot;VTIMEZONE&quot;,):
+                    continue
+                if component.hasDuplicatePrivateComments(doFix):
+                    return True
+        else:
+            attendee_refs = set()
+            for prop in tuple(self.properties(&quot;X-CALENDARSERVER-ATTENDEE-COMMENT&quot;)):
+                ref = prop.parameterValue(&quot;X-CALENDARSERVER-ATTENDEE-REF&quot;)
+                if ref in attendee_refs:
+                    if doFix:
+                        self.removeProperty(prop)
+                    else:
+                        return True
+                attendee_refs.add(ref)
+        return False
+
+
+
</ins><span class="cx"> # #
</span><span class="cx"> # Timezones
</span><span class="cx"> # #
</span></span></pre></div>
<a id="CalendarServertrunktwistedcaldavstdconfigpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twistedcaldav/stdconfig.py (12020 => 12021)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twistedcaldav/stdconfig.py        2013-12-03 19:33:06 UTC (rev 12020)
+++ CalendarServer/trunk/twistedcaldav/stdconfig.py        2013-12-03 19:35:19 UTC (rev 12021)
</span><span class="lines">@@ -619,6 +619,8 @@
</span><span class="cx">     &quot;EnableDefaultAlarms&quot; : True, # Support for default alarms generated by the server
</span><span class="cx">     &quot;RemoveDuplicateAlarms&quot;: True, # Remove duplicate alarms on PUT
</span><span class="cx"> 
</span><ins>+    &quot;RemoveDuplicatePrivateComments&quot;: True, # Remove duplicate private comments on PUT
+
</ins><span class="cx">     # CardDAV Features
</span><span class="cx">     &quot;DirectoryAddressBook&quot;: {
</span><span class="cx">         &quot;Enabled&quot;: True,
</span></span></pre></div>
<a id="CalendarServertrunktwistedcaldavstorebridgepy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twistedcaldav/storebridge.py (12020 => 12021)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twistedcaldav/storebridge.py        2013-12-03 19:33:06 UTC (rev 12020)
+++ CalendarServer/trunk/twistedcaldav/storebridge.py        2013-12-03 19:35:19 UTC (rev 12021)
</span><span class="lines">@@ -58,7 +58,7 @@
</span><span class="cx">     TooManyAttendeesError, InvalidCalendarAccessError, ValidOrganizerError, \
</span><span class="cx">     InvalidPerUserDataMerge, \
</span><span class="cx">     AttendeeAllowedError, ResourceDeletedError, InvalidAttachmentOperation, \
</span><del>-    ShareeAllowedError
</del><ins>+    ShareeAllowedError, DuplicatePrivateCommentsError
</ins><span class="cx"> from txdav.carddav.iaddressbookstore import KindChangeNotAllowedError, \
</span><span class="cx">     GroupWithUnsharedAddressNotAllowedError
</span><span class="cx"> from txdav.common.datastore.sql_tables import _BIND_MODE_READ, _BIND_MODE_WRITE, \
</span><span class="lines">@@ -2647,6 +2647,7 @@
</span><span class="cx">         TooManyInstancesError: MaxInstances.fromString(str(config.MaxAllowedInstances)),
</span><span class="cx">         AttachmentStoreValidManagedID: (caldav_namespace, &quot;valid-managed-id&quot;),
</span><span class="cx">         ShareeAllowedError: (calendarserver_namespace, &quot;sharee-privilege-needed&quot;,),
</span><ins>+        DuplicatePrivateCommentsError: (calendarserver_namespace, &quot;no-duplicate-private-comments&quot;,),
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     StoreMoveExceptionsStatusErrors = set((
</span></span></pre></div>
<a id="CalendarServertrunktwistedcaldavtesttest_icalendarpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twistedcaldav/test/test_icalendar.py (12020 => 12021)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twistedcaldav/test/test_icalendar.py        2013-12-03 19:33:06 UTC (rev 12020)
+++ CalendarServer/trunk/twistedcaldav/test/test_icalendar.py        2013-12-03 19:35:19 UTC (rev 12021)
</span><span class="lines">@@ -10128,3 +10128,322 @@
</span><span class="cx">             ical2 = Component.fromString(calendar)
</span><span class="cx">             ical2.onlyPastInstances(rid)
</span><span class="cx">             self.assertEqual(str(ical2), split_past.replace(&quot;\n&quot;, &quot;\r\n&quot;), &quot;Failed past: %s&quot; % (title,))
</span><ins>+
+
+    def test_hasDuplicatePrivateComments(self):
+        &quot;&quot;&quot;
+        Test that L{Component.hasDuplicatePrivateComments} correctly detects, but does not fix, duplicate private comments.
+        &quot;&quot;&quot;
+
+        data = (
+            (
+                &quot;No comments&quot;,
+                &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20080601T120000Z
+DURATION:PT1H
+DTSTAMP:20080601T120000Z
+RRULE:FREQ=DAILY
+SUMMARY:Test
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;,
+                False,
+            ),
+
+            (
+                &quot;One comment&quot;,
+                &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20080601T120000Z
+DURATION:PT1H
+DTSTAMP:20080601T120000Z
+RRULE:FREQ=DAILY
+SUMMARY:Test
+X-CALENDARSERVER-ATTENDEE-COMMENT;X-CALENDARSERVER-ATTENDEE-REF=&quot;urn:uuid:user01&quot;;X-CALENDARSERVER-DTSTAMP=20130606T152554Z:Message1
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;,
+                False,
+            ),
+
+            (
+                &quot;Two different comments&quot;,
+                &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20080601T120000Z
+DURATION:PT1H
+DTSTAMP:20080601T120000Z
+RRULE:FREQ=DAILY
+SUMMARY:Test
+X-CALENDARSERVER-ATTENDEE-COMMENT;X-CALENDARSERVER-ATTENDEE-REF=&quot;urn:uuid:user01&quot;;X-CALENDARSERVER-DTSTAMP=20130606T152554Z:Message1
+X-CALENDARSERVER-ATTENDEE-COMMENT;X-CALENDARSERVER-ATTENDEE-REF=&quot;urn:uuid:user02&quot;;X-CALENDARSERVER-DTSTAMP=20130606T152554Z:Message2
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;,
+                False,
+            ),
+
+            (
+                &quot;Two duplicates, one different&quot;,
+                &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20080601T120000Z
+DURATION:PT1H
+DTSTAMP:20080601T120000Z
+RRULE:FREQ=DAILY
+SUMMARY:Test
+X-CALENDARSERVER-ATTENDEE-COMMENT;X-CALENDARSERVER-ATTENDEE-REF=&quot;urn:uuid:user01&quot;;X-CALENDARSERVER-DTSTAMP=20130606T152554Z:Message1
+X-CALENDARSERVER-ATTENDEE-COMMENT;X-CALENDARSERVER-ATTENDEE-REF=&quot;urn:uuid:user02&quot;;X-CALENDARSERVER-DTSTAMP=20130606T152554Z:Message2
+X-CALENDARSERVER-ATTENDEE-COMMENT;X-CALENDARSERVER-ATTENDEE-REF=&quot;urn:uuid:user01&quot;;X-CALENDARSERVER-DTSTAMP=20130606T152554Z:Message1
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;,
+                True,
+            ),
+
+            (
+                &quot;No duplicates in two components&quot;,
+                &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20080601T120000Z
+DURATION:PT1H
+DTSTAMP:20080601T120000Z
+RRULE:FREQ=DAILY
+SUMMARY:Test
+X-CALENDARSERVER-ATTENDEE-COMMENT;X-CALENDARSERVER-ATTENDEE-REF=&quot;urn:uuid:user01&quot;;X-CALENDARSERVER-DTSTAMP=20130606T152554Z:Message1
+X-CALENDARSERVER-ATTENDEE-COMMENT;X-CALENDARSERVER-ATTENDEE-REF=&quot;urn:uuid:user02&quot;;X-CALENDARSERVER-DTSTAMP=20130606T152554Z:Message2
+X-CALENDARSERVER-ATTENDEE-COMMENT;X-CALENDARSERVER-ATTENDEE-REF=&quot;urn:uuid:user03&quot;;X-CALENDARSERVER-DTSTAMP=20130606T152554Z:Message3
+END:VEVENT
+BEGIN:VEVENT
+UID:12345-67890
+RECURRENCE-ID:20080602T120000Z
+DTSTART:20080602T120000Z
+DURATION:PT1H
+DTSTAMP:20080601T120000Z
+SUMMARY:Test
+X-CALENDARSERVER-ATTENDEE-COMMENT;X-CALENDARSERVER-ATTENDEE-REF=&quot;urn:uuid:user02&quot;;X-CALENDARSERVER-DTSTAMP=20130606T152554Z:Message2
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;,
+                False,
+            ),
+
+            (
+                &quot;Two duplicates in one component, three different in another&quot;,
+                &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20080601T120000Z
+DURATION:PT1H
+DTSTAMP:20080601T120000Z
+RRULE:FREQ=DAILY
+SUMMARY:Test
+X-CALENDARSERVER-ATTENDEE-COMMENT;X-CALENDARSERVER-ATTENDEE-REF=&quot;urn:uuid:user01&quot;;X-CALENDARSERVER-DTSTAMP=20130606T152554Z:Message1
+X-CALENDARSERVER-ATTENDEE-COMMENT;X-CALENDARSERVER-ATTENDEE-REF=&quot;urn:uuid:user02&quot;;X-CALENDARSERVER-DTSTAMP=20130606T152554Z:Message2
+X-CALENDARSERVER-ATTENDEE-COMMENT;X-CALENDARSERVER-ATTENDEE-REF=&quot;urn:uuid:user03&quot;;X-CALENDARSERVER-DTSTAMP=20130606T152554Z:Message3
+END:VEVENT
+BEGIN:VEVENT
+UID:12345-67890
+RECURRENCE-ID:20080602T120000Z
+DTSTART:20080602T120000Z
+DURATION:PT1H
+DTSTAMP:20080601T120000Z
+SUMMARY:Test
+X-CALENDARSERVER-ATTENDEE-COMMENT;X-CALENDARSERVER-ATTENDEE-REF=&quot;urn:uuid:user02&quot;;X-CALENDARSERVER-DTSTAMP=20130606T152554Z:Message2
+X-CALENDARSERVER-ATTENDEE-COMMENT;X-CALENDARSERVER-ATTENDEE-REF=&quot;urn:uuid:user02&quot;;X-CALENDARSERVER-DTSTAMP=20130606T152554Z:Message2
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;,
+                True,
+            ),
+        )
+
+        for title, txt, result in data:
+            component = Component.fromString(txt)
+            self.assertEqual(component.hasDuplicatePrivateComments(doFix=False), result, msg=title)
+            self.assertEqual(normalize_iCalStr(component), normalize_iCalStr(txt), msg=title)
+
+
+    def test_hasDuplicatePrivateComments_withFix(self):
+        &quot;&quot;&quot;
+        Test that L{Component.hasDuplicatePrivateComments} correctly removes duplicate comments.
+        &quot;&quot;&quot;
+
+        data = (
+            (
+                &quot;No comments&quot;,
+                &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20080601T120000Z
+DURATION:PT1H
+DTSTAMP:20080601T120000Z
+RRULE:FREQ=DAILY
+SUMMARY:Test
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;,
+                &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20080601T120000Z
+DURATION:PT1H
+DTSTAMP:20080601T120000Z
+RRULE:FREQ=DAILY
+SUMMARY:Test
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;,
+                False,
+            ),
+
+            (
+                &quot;One comment&quot;,
+                &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20080601T120000Z
+DURATION:PT1H
+DTSTAMP:20080601T120000Z
+RRULE:FREQ=DAILY
+SUMMARY:Test
+X-CALENDARSERVER-ATTENDEE-COMMENT;X-CALENDARSERVER-ATTENDEE-REF=&quot;urn:uuid:user01&quot;;X-CALENDARSERVER-DTSTAMP=20130606T152554Z:Message1
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;,
+                &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20080601T120000Z
+DURATION:PT1H
+DTSTAMP:20080601T120000Z
+RRULE:FREQ=DAILY
+SUMMARY:Test
+X-CALENDARSERVER-ATTENDEE-COMMENT;X-CALENDARSERVER-ATTENDEE-REF=&quot;urn:uuid:user01&quot;;X-CALENDARSERVER-DTSTAMP=20130606T152554Z:Message1
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;,
+                False,
+            ),
+
+            (
+                &quot;Two different comments&quot;,
+                &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20080601T120000Z
+DURATION:PT1H
+DTSTAMP:20080601T120000Z
+RRULE:FREQ=DAILY
+SUMMARY:Test
+X-CALENDARSERVER-ATTENDEE-COMMENT;X-CALENDARSERVER-ATTENDEE-REF=&quot;urn:uuid:user01&quot;;X-CALENDARSERVER-DTSTAMP=20130606T152554Z:Message1
+X-CALENDARSERVER-ATTENDEE-COMMENT;X-CALENDARSERVER-ATTENDEE-REF=&quot;urn:uuid:user02&quot;;X-CALENDARSERVER-DTSTAMP=20130606T152554Z:Message2
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;,
+                &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20080601T120000Z
+DURATION:PT1H
+DTSTAMP:20080601T120000Z
+RRULE:FREQ=DAILY
+SUMMARY:Test
+X-CALENDARSERVER-ATTENDEE-COMMENT;X-CALENDARSERVER-ATTENDEE-REF=&quot;urn:uuid:user01&quot;;X-CALENDARSERVER-DTSTAMP=20130606T152554Z:Message1
+X-CALENDARSERVER-ATTENDEE-COMMENT;X-CALENDARSERVER-ATTENDEE-REF=&quot;urn:uuid:user02&quot;;X-CALENDARSERVER-DTSTAMP=20130606T152554Z:Message2
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;,
+                False,
+            ),
+
+            (
+                &quot;Two duplicates, one different&quot;,
+                &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20080601T120000Z
+DURATION:PT1H
+DTSTAMP:20080601T120000Z
+RRULE:FREQ=DAILY
+SUMMARY:Test
+X-CALENDARSERVER-ATTENDEE-COMMENT;X-CALENDARSERVER-ATTENDEE-REF=&quot;urn:uuid:user01&quot;;X-CALENDARSERVER-DTSTAMP=20130606T152554Z:Message1
+END:VEVENT
+BEGIN:VEVENT
+UID:12345-67890
+RECURRENCE-ID:20080602T120000Z
+DTSTART:20080602T120000Z
+DURATION:PT1H
+DTSTAMP:20080601T120000Z
+SUMMARY:Test
+X-CALENDARSERVER-ATTENDEE-COMMENT;X-CALENDARSERVER-ATTENDEE-REF=&quot;urn:uuid:user01&quot;;X-CALENDARSERVER-DTSTAMP=20130606T152554Z:Message1
+X-CALENDARSERVER-ATTENDEE-COMMENT;X-CALENDARSERVER-ATTENDEE-REF=&quot;urn:uuid:user02&quot;;X-CALENDARSERVER-DTSTAMP=20130606T152554Z:Message2
+X-CALENDARSERVER-ATTENDEE-COMMENT;X-CALENDARSERVER-ATTENDEE-REF=&quot;urn:uuid:user01&quot;;X-CALENDARSERVER-DTSTAMP=20130606T152554Z:Message1
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;,
+                &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20080601T120000Z
+DURATION:PT1H
+DTSTAMP:20080601T120000Z
+RRULE:FREQ=DAILY
+SUMMARY:Test
+X-CALENDARSERVER-ATTENDEE-COMMENT;X-CALENDARSERVER-ATTENDEE-REF=&quot;urn:uuid:user01&quot;;X-CALENDARSERVER-DTSTAMP=20130606T152554Z:Message1
+END:VEVENT
+BEGIN:VEVENT
+UID:12345-67890
+RECURRENCE-ID:20080602T120000Z
+DTSTART:20080602T120000Z
+DURATION:PT1H
+DTSTAMP:20080601T120000Z
+SUMMARY:Test
+X-CALENDARSERVER-ATTENDEE-COMMENT;X-CALENDARSERVER-ATTENDEE-REF=&quot;urn:uuid:user01&quot;;X-CALENDARSERVER-DTSTAMP=20130606T152554Z:Message1
+X-CALENDARSERVER-ATTENDEE-COMMENT;X-CALENDARSERVER-ATTENDEE-REF=&quot;urn:uuid:user02&quot;;X-CALENDARSERVER-DTSTAMP=20130606T152554Z:Message2
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;,
+                False,
+            ),
+        )
+
+        for title, txt, result, result_changed in data:
+            component = Component.fromString(txt)
+            changed = component.hasDuplicatePrivateComments(doFix=True)
+            self.assertEqual(sorted(normalize_iCalStr(component).splitlines()), sorted(normalize_iCalStr(result).splitlines()), msg=title)
+            self.assertEqual(changed, result_changed, msg=title)
</ins></span></pre></div>
<a id="CalendarServertrunktxdavcaldavdatastoresqlpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/caldav/datastore/sql.py (12020 => 12021)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/caldav/datastore/sql.py        2013-12-03 19:33:06 UTC (rev 12020)
+++ CalendarServer/trunk/txdav/caldav/datastore/sql.py        2013-12-03 19:35:19 UTC (rev 12021)
</span><span class="lines">@@ -73,7 +73,7 @@
</span><span class="cx">     AttendeeAllowedError, InvalidPerUserDataMerge, ComponentUpdateState, \
</span><span class="cx">     ValidOrganizerError, ShareeAllowedError, ComponentRemoveState, \
</span><span class="cx">     InvalidDefaultCalendar, \
</span><del>-    InvalidAttachmentOperation
</del><ins>+    InvalidAttachmentOperation, DuplicatePrivateCommentsError
</ins><span class="cx"> from txdav.caldav.icalendarstore import QuotaExceeded
</span><span class="cx"> from txdav.common.datastore.sql import CommonHome, CommonHomeChild, \
</span><span class="cx">     CommonObjectResource, ECALENDARTYPE
</span><span class="lines">@@ -1790,7 +1790,14 @@
</span><span class="cx"> 
</span><span class="cx">             self.hasPrivateComment = new_has_private_comments
</span><span class="cx"> 
</span><ins>+            # Some clients appear to be buggy and are duplicating the &quot;X-CALENDARSERVER-ATTENDEE-COMMENT&quot; comment. We want
+            # to raise an error to prevent that so the client bugs can be tracked down.
</ins><span class="cx"> 
</span><ins>+            # Look for properties with duplicate &quot;X-CALENDARSERVER-ATTENDEE-REF&quot; values in the same component
+            if component.hasDuplicatePrivateComments(doFix=config.RemoveDuplicatePrivateComments):
+                raise DuplicatePrivateCommentsError(&quot;Duplicate X-CALENDARSERVER-ATTENDEE-COMMENT properties present.&quot;)
+
+
</ins><span class="cx">     @inlineCallbacks
</span><span class="cx">     def replaceMissingToDoProperties(self, calendar, inserting, internal_state):
</span><span class="cx">         &quot;&quot;&quot;
</span></span></pre></div>
<a id="CalendarServertrunktxdavcaldavicalendarstorepy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/caldav/icalendarstore.py (12020 => 12021)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/caldav/icalendarstore.py        2013-12-03 19:33:06 UTC (rev 12020)
+++ CalendarServer/trunk/txdav/caldav/icalendarstore.py        2013-12-03 19:35:19 UTC (rev 12021)
</span><span class="lines">@@ -740,6 +740,13 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+class DuplicatePrivateCommentsError(CommonStoreError):
+    &quot;&quot;&quot;
+    Calendar data cannot contain duplicate private comment properties.
+    &quot;&quot;&quot;
+
+
+
</ins><span class="cx"> class InvalidPerUserDataMerge(CommonStoreError):
</span><span class="cx">     &quot;&quot;&quot;
</span><span class="cx">     Per-user data merge failed.
</span></span></pre>
</div>
</div>

</body>
</html>