[CalendarServer-changes] [1783]

source_changes at macosforge.org source_changes at macosforge.org
Fri Aug 10 14:20:10 PDT 2007


Revision: 1783
          http://trac.macosforge.org/projects/calendarserver/changeset/1783
Author:   cdaboo at apple.com
Date:     2007-08-10 14:20:10 -0700 (Fri, 10 Aug 2007)

Log Message:
-----------
Fix encoding of xml data: '<' was not being encoded. ']]>' used &lt; instead of &gt;. Also, we cannot test for ']]>'
as for some reason the parser breaks that down into two separate PCDataElements of ']]' amd '>'. So instead we encode
all '>' characters. Also catch the exception for the invalid xml parse of the xattr and turn that into a 400.

Modified Paths:
--------------
    CalDAVTester/trunk/scripts/tests/proppatch.xml
    CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.element.base.patch
    CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.xattrprops.patch

Added Paths:
-----------
    CalDAVTester/trunk/Resource/proppatches/8.xml
    CalDAVTester/trunk/Resource/proppatches/9.xml

Added: CalDAVTester/trunk/Resource/proppatches/8.xml
===================================================================
--- CalDAVTester/trunk/Resource/proppatches/8.xml	                        (rev 0)
+++ CalDAVTester/trunk/Resource/proppatches/8.xml	2007-08-10 21:20:10 UTC (rev 1783)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<D:propertyupdate xmlns:D="DAV:">
+<D:set>
+<D:prop>
+<D:displayname>calendar &lt;- &amp; ]]&gt;</D:displayname>
+</D:prop>
+</D:set>
+</D:propertyupdate>

Added: CalDAVTester/trunk/Resource/proppatches/9.xml
===================================================================
--- CalDAVTester/trunk/Resource/proppatches/9.xml	                        (rev 0)
+++ CalDAVTester/trunk/Resource/proppatches/9.xml	2007-08-10 21:20:10 UTC (rev 1783)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<D:propfind xmlns:D="DAV:">
+<D:prop>
+<D:displayname/>
+</D:prop>
+</D:propfind>

Modified: CalDAVTester/trunk/scripts/tests/proppatch.xml
===================================================================
--- CalDAVTester/trunk/scripts/tests/proppatch.xml	2007-08-10 19:27:34 UTC (rev 1782)
+++ CalDAVTester/trunk/scripts/tests/proppatch.xml	2007-08-10 21:20:10 UTC (rev 1783)
@@ -24,7 +24,7 @@
 	<start/>
 	
 	<test-suite name='prop patches' ignore='no'>
-		<test name='1' ignore="no">
+		<test name='1' ignore='no'>
 			<description>PROPPATCH of details: good</description>
 			<request print-response='no'>
 				<method>PROPPATCH</method>
@@ -61,7 +61,7 @@
 				</verify>
 			</request>
 		</test>
-		<test name='2' ignore="no">
+		<test name='2' ignore='no'>
 			<description>PROPPATCH of details: remove it</description>
 			<request print-response='no'>
 				<method>PROPPATCH</method>
@@ -100,7 +100,7 @@
 				</verify>
 			</request>
 		</test>
-		<test name='3'>
+		<test name='3' ignore='no'>
 			<description>PROPPATCH remove non-existant</description>
 			<request print-response='no'>
 				<method>PROPPATCH</method>
@@ -117,7 +117,7 @@
 				</verify>
 			</request>
 		</test>
-		<test name='4'>
+		<test name='4' ignore='no'>
 			<description>PROPPATCH of resourcetype: fails</description>
 			<request print-response='no'>
 				<method>PROPPATCH</method>
@@ -158,6 +158,41 @@
 				</verify>
 			</request>
 		</test>
+		<test name='5'>
+			<description>PROPPATCH of encoded value</description>
+			<request print-response='no'>
+				<method>PROPPATCH</method>
+				<data>
+					<content-type>text/xml; charset=utf-8</content-type>
+					<filepath>Resource/proppatches/8.xml</filepath>
+				</data>
+				<verify>
+					<callback>propfindItems</callback>
+					<arg>
+						<name>okprops</name>
+						<value>DAV:displayname</value>
+					</arg>
+				</verify>
+			</request>
+			<request print-response='no'>
+				<method>PROPFIND</method>
+				<header>
+					<name>Depth</name>
+					<value>0</value>
+				</header>
+				<data>
+					<content-type>text/xml; charset=utf-8</content-type>
+					<filepath>Resource/proppatches/9.xml</filepath>
+				</data>
+				<verify>
+					<callback>propfindItems</callback>
+					<arg>
+						<name>okprops</name>
+						<value>DAV:displayname$calendar &amp;lt;- &amp;amp; ]]&amp;gt;</value>
+					</arg>
+				</verify>
+			</request>
+		</test>
 	</test-suite>
 	
 	<test-suite name='prop patch property attributes'>

Modified: CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.element.base.patch
===================================================================
--- CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.element.base.patch	2007-08-10 19:27:34 UTC (rev 1782)
+++ CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.element.base.patch	2007-08-10 21:20:10 UTC (rev 1783)
@@ -208,15 +208,15 @@
 +        # Do escaping/CDATA behavior
 +        if "\r" in self.data or "\n" in self.data:
 +            # Do CDATA
-+            cdata = "<![CDATA[%s]]>" % (self.data.replace("]]>", "]]&lt;"),)
++            cdata = "<![CDATA[%s]]>" % (self.data.replace("]]>", "]]&gt;"),)
 +        else:
 +            cdata = self.data
 +            if "&" in cdata:
 +                cdata = cdata.replace("&", "&amp;")
 +            if "<" in cdata:
-+                cdata = cdata.replace("&", "&lt;")
-+            if "]]>" in cdata:
-+                cdata = cdata.replace("]]>", "]]&lt;")
++                cdata = cdata.replace("<", "&lt;")
++            if ">" in cdata:
++                cdata = cdata.replace(">", "&gt;")
 +
 +        output.write(cdata)
 +

Modified: CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.xattrprops.patch
===================================================================
--- CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.xattrprops.patch	2007-08-10 19:27:34 UTC (rev 1782)
+++ CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.xattrprops.patch	2007-08-10 21:20:10 UTC (rev 1783)
@@ -31,17 +31,30 @@
          return r
  
      def _decode(clazz, name):
-@@ -109,7 +104,16 @@
-         return doc.root_element
+@@ -104,12 +99,27 @@
+                 "No such property: {%s}%s" % qname
+             ))
  
+-        doc = davxml.WebDAVDocument.fromString(value)
++        try:
++            doc = davxml.WebDAVDocument.fromString(value)
+ 
+-        return doc.root_element
++            return doc.root_element
++        except ValueError:
++            raise HTTPError(StatusResponse(
++                responsecode.BAD_REQUEST,
++                "Invalid property value stored on server: {%s}%s %s" % (qname[0], qname[1], value,)
++            ))
+ 
      def set(self, property):
 -        self.attrs[self._encode(property.qname())] = property.toxml()
 +        for n in range(20):
 +            try:
 +                self.attrs[self._encode(property.qname())] = property.toxml()
 +            except IOError, error:
-+		if error.errno != EAGAIN:
-+		    raise
++                if error.errno != EAGAIN:
++                    raise
 +                sleep(random() / 10) # OMG Brutal Hax
 +            else:
 +                break

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20070810/6a2aa0d4/attachment.html


More information about the calendarserver-changes mailing list