summaryrefslogtreecommitdiff
path: root/addons/document_webdav
diff options
context:
space:
mode:
authorP. Christeas <p_christ@hol.gr>2010-10-12 13:40:44 +0300
committerP. Christeas <p_christ@hol.gr>2010-10-12 13:40:44 +0300
commitf7ce71c475604afca3ca1a13f648fbb944487393 (patch)
tree7d8b2813420cf87eabc23d2dd25c0dd1a07c310c /addons/document_webdav
parent371ceab425cdd48e39267adbb108729b5900cab8 (diff)
Doc webdav: hack minidom to put proper quotes at ETag. Status first.
bzr revid: p_christ@hol.gr-20101012104044-1uq9x7k93aku7ls1
Diffstat (limited to 'addons/document_webdav')
-rw-r--r--addons/document_webdav/webdav.py37
1 files changed, 27 insertions, 10 deletions
diff --git a/addons/document_webdav/webdav.py b/addons/document_webdav/webdav.py
index 86fd8cd9e71..0a9f4cd1111 100644
--- a/addons/document_webdav/webdav.py
+++ b/addons/document_webdav/webdav.py
@@ -22,6 +22,8 @@
import xml.dom.minidom
domimpl = xml.dom.minidom.getDOMImplementation()
+from xml.dom.minicompat import StringTypes
+
import urlparse
import urllib
from osv import osv
@@ -35,6 +37,21 @@ from http://code.google.com/p/pywebdav/downloads/detail?name=PyWebDAV-0.9.4.tar.
import tools
+class Text2(xml.dom.minidom.Text):
+ def writexml(self, writer, indent="", addindent="", newl=""):
+ data = "%s%s%s" % (indent, self.data, newl)
+ data = data.replace("&", "&amp;").replace("<", "&lt;")
+ data = data.replace(">", "&gt;")
+ writer.write(data)
+
+def createText2Node(doc, data):
+ if not isinstance(data, StringTypes):
+ raise TypeError, "node contents must be a string"
+ t = Text2()
+ t.data = data
+ t.ownerDocument = doc
+ return t
+
super_mk_prop_response = PROPFIND.mk_prop_response
def mk_prop_response(self, uri, good_props, bad_props, doc):
@@ -116,7 +133,7 @@ def mk_prop_response(self, uri, good_props, bad_props, doc):
# ( 'elem', 'ns:', [('sub-elem1', 'ns1'), ...]
_prop_elem_child(ve, v[1], v[2], ns_prefix)
else:
- vt =doc.createTextNode(tools.ustr(v[2]))
+ vt=createText2Node(doc,tools.ustr(v[2]))
ve.appendChild(vt)
if len(v) > 3 and v[3]:
assert isinstance(v[3], dict)
@@ -124,7 +141,7 @@ def mk_prop_response(self, uri, good_props, bad_props, doc):
ve.setAttribute(ak, av)
pnode.appendChild(ve)
else:
- ve=doc.createTextNode(tools.ustr(v))
+ ve=createText2Node(doc, tools.ustr(v))
pnode.appendChild(ve)
# write href information
@@ -143,6 +160,10 @@ def mk_prop_response(self, uri, good_props, bad_props, doc):
ps=doc.createElement("D:propstat")
if good_props:
re.appendChild(ps)
+ s=doc.createElement("D:status")
+ t=doc.createTextNode("HTTP/1.1 200 OK")
+ s.appendChild(t)
+ ps.appendChild(s)
gp=doc.createElement("D:prop")
for ns in good_props.keys():
@@ -156,10 +177,6 @@ def mk_prop_response(self, uri, good_props, bad_props, doc):
_prop_child(gp, ns, p, v)
ps.appendChild(gp)
- s=doc.createElement("D:status")
- t=doc.createTextNode("HTTP/1.1 200 OK")
- s.appendChild(t)
- ps.appendChild(s)
re.appendChild(ps)
# now write the errors!
@@ -169,6 +186,10 @@ def mk_prop_response(self, uri, good_props, bad_props, doc):
for ecode in bad_props.keys():
ps=doc.createElement("D:propstat")
re.appendChild(ps)
+ s=doc.createElement("D:status")
+ t=doc.createTextNode(utils.gen_estring(ecode))
+ s.appendChild(t)
+ ps.appendChild(s)
bp=doc.createElement("D:prop")
ps.appendChild(bp)
@@ -182,10 +203,6 @@ def mk_prop_response(self, uri, good_props, bad_props, doc):
pe=doc.createElement(ns_prefix+str(p))
bp.appendChild(pe)
- s=doc.createElement("D:status")
- t=doc.createTextNode(utils.gen_estring(ecode))
- s.appendChild(t)
- ps.appendChild(s)
re.appendChild(ps)
# return the new response element