[CalendarServer-changes] [10985] PyCalendar/trunk/src/pycalendar

source_changes at macosforge.org source_changes at macosforge.org
Tue Apr 2 20:23:23 PDT 2013


Revision: 10985
          http://trac.calendarserver.org//changeset/10985
Author:   cdaboo at apple.com
Date:     2013-04-02 20:23:23 -0700 (Tue, 02 Apr 2013)
Log Message:
-----------
Handle \n in URI values.

Modified Paths:
--------------
    PyCalendar/trunk/src/pycalendar/tests/test_property.py
    PyCalendar/trunk/src/pycalendar/urivalue.py

Modified: PyCalendar/trunk/src/pycalendar/tests/test_property.py
===================================================================
--- PyCalendar/trunk/src/pycalendar/tests/test_property.py	2013-04-03 01:26:19 UTC (rev 10984)
+++ PyCalendar/trunk/src/pycalendar/tests/test_property.py	2013-04-03 03:23:23 UTC (rev 10985)
@@ -1,5 +1,5 @@
 ##
-#    Copyright (c) 2007-2012 Cyrus Daboo. All rights reserved.
+#    Copyright (c) 2007-2013 Cyrus Daboo. All rights reserved.
 #
 #    Licensed under the Apache License, Version 2.0 (the "License");
 #    you may not use this file except in compliance with the License.
@@ -50,6 +50,7 @@
         # Various parameters
         "DTSTART;TZID=\"Somewhere, else\":20060226T120000",
         "ATTENDEE;PARTSTAT=ACCEPTED;ROLE=CHAIR:mailto:jdoe at example.com",
+        "X-APPLE-STRUCTURED-LOCATION;VALUE=URI;X-APPLE-ABUID=ab\\://Work;X-TITLE=\"10\\n XX S. XXX Dr.\\nSuite XXX\\nXX XX XXXXX\\nUnited States\":\"geo:11.111111,-11.111111\"",
 
         # Parameter escaping
         "ATTENDEE;CN=My ^'Test^' Name;ROLE=CHAIR:mailto:jdoe at example.com",
@@ -61,7 +62,7 @@
         for data in TestProperty.test_data:
             prop = PyCalendarProperty()
             prop.parse(data)
-            propstr = str(prop)
+            propstr = str(prop).replace("\r\n ", "")
             self.assertEqual(propstr[:-2], data, "Failed parse/generate: %s to %s" % (data, propstr,))
 
 

Modified: PyCalendar/trunk/src/pycalendar/urivalue.py
===================================================================
--- PyCalendar/trunk/src/pycalendar/urivalue.py	2013-04-03 01:26:19 UTC (rev 10984)
+++ PyCalendar/trunk/src/pycalendar/urivalue.py	2013-04-03 03:23:23 UTC (rev 10985)
@@ -1,5 +1,5 @@
 ##
-#    Copyright (c) 2007-2012 Cyrus Daboo. All rights reserved.
+#    Copyright (c) 2007-2013 Cyrus Daboo. All rights reserved.
 #
 #    Licensed under the Apache License, Version 2.0 (the "License");
 #    you may not use this file except in compliance with the License.
@@ -36,4 +36,20 @@
             # No decoding required
             self.mValue = data
 
+
+    # os - StringIO object
+    def generate(self, os):
+        """
+        Handle a client bug where it sometimes includes a \n in the value and we need
+        to make sure that gets encoded rather than included literally which would break syntax.
+        """
+        if '\n' in self.mValue:
+            try:
+                # No encoding required
+                os.write(self.mValue.replace("\n", "\\n"))
+            except:
+                pass
+        else:
+            super(PyCalendarURIValue, self).generate(os)
+
 PyCalendarValue.registerType(PyCalendarValue.VALUETYPE_URI, PyCalendarURIValue, xmldefs.value_uri)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130402/490ee117/attachment.html>


More information about the calendarserver-changes mailing list