Commit 8ed5d5d8 by rfkelly0

fix some malformed XML in DAVFS

parent 86038e88
...@@ -166,7 +166,10 @@ class DAVFS(FS): ...@@ -166,7 +166,10 @@ class DAVFS(FS):
"""Convert a server-side URL into a client-side path.""" """Convert a server-side URL into a client-side path."""
path = urlunquote(urlparse(url).path) path = urlunquote(urlparse(url).path)
root = self._url_p.path root = self._url_p.path
return path[len(root)-1:].decode("utf8") path = path[len(root)-1:].decode("utf8")
while path.endswith("/"):
path = path[:-1]
return path
def _isurl(self,path,url): def _isurl(self,path,url):
"""Check whether the given URL corresponds to the given local path.""" """Check whether the given URL corresponds to the given local path."""
...@@ -187,7 +190,7 @@ class DAVFS(FS): ...@@ -187,7 +190,7 @@ class DAVFS(FS):
resp = self._raw_request(url,method,body,headers) resp = self._raw_request(url,method,body,headers)
# Loop to retry for redirects and authentication responses. # Loop to retry for redirects and authentication responses.
while resp.status in (301,302,401,403): while resp.status in (301,302,401,403):
resp.close() #resp.close()
if resp.status in (301,302,): if resp.status in (301,302,):
visited.append(url) visited.append(url)
url = resp.getheader("Location",None) url = resp.getheader("Location",None)
...@@ -549,7 +552,7 @@ class DAVFS(FS): ...@@ -549,7 +552,7 @@ class DAVFS(FS):
If the server is able to send responses in chunked encoding, then If the server is able to send responses in chunked encoding, then
this can substantially speed up iterating over the results. this can substantially speed up iterating over the results.
""" """
pf = propfind(prop="<prop xmlns:D='DAV:'>" + props + "</prop>") pf = propfind(prop="<D:prop xmlns:D='DAV:'>"+props+"</D:prop>")
response = self._request(path,"PROPFIND",pf.render(),{"Depth":"1"}) response = self._request(path,"PROPFIND",pf.render(),{"Depth":"1"})
try: try:
if response.status == 404: if response.status == 404:
...@@ -670,9 +673,9 @@ class DAVFS(FS): ...@@ -670,9 +673,9 @@ class DAVFS(FS):
(namespaceURI,localName) = self._split_xattr(name) (namespaceURI,localName) = self._split_xattr(name)
# TODO: encode xml character entities in the namespace # TODO: encode xml character entities in the namespace
if namespaceURI: if namespaceURI:
pf = propfind(prop="<prop xmlns='"+namespaceURI+"'><"+localName+" /></prop>") pf = propfind(prop="<D:prop xmlns:D='DAV:' xmlns='"+namespaceURI+"'><"+localName+" /></D:prop>")
else: else:
pf = propfind(prop="<prop><"+localName+" /></prop>") pf = propfind(prop="<D:prop xmlns:D='DAV:'><"+localName+" /></D:prop>")
response = self._request(path,"PROPFIND",pf.render(),{"Depth":"0"}) response = self._request(path,"PROPFIND",pf.render(),{"Depth":"0"})
try: try:
if response.status != 207: if response.status != 207:
...@@ -706,7 +709,7 @@ class DAVFS(FS): ...@@ -706,7 +709,7 @@ class DAVFS(FS):
else: else:
p = "<%s>%s</%s>" % (localName,value,localName) p = "<%s>%s</%s>" % (localName,value,localName)
pu = propertyupdate() pu = propertyupdate()
pu.commands.append(set(props="<prop>"+p+"</prop>")) pu.commands.append(set(props="<D:prop xmlns:D='DAV:'>"+p+"</D:prop>"))
response = self._request(path,"PROPPATCH",pu.render(),{"Depth":"0"}) response = self._request(path,"PROPPATCH",pu.render(),{"Depth":"0"})
response.close() response.close()
if response.status < 200 or response.status >= 300: if response.status < 200 or response.status >= 300:
...@@ -720,7 +723,7 @@ class DAVFS(FS): ...@@ -720,7 +723,7 @@ class DAVFS(FS):
else: else:
p = "<%s />" % (localName,) p = "<%s />" % (localName,)
pu = propertyupdate() pu = propertyupdate()
pu.commands.append(remove(props="<prop>"+p+"</prop>")) pu.commands.append(remove(props="<D:prop xmlns:D='DAV:'>"+p+"</D:prop>"))
response = self._request(path,"PROPPATCH",pu.render(),{"Depth":"0"}) response = self._request(path,"PROPPATCH",pu.render(),{"Depth":"0"})
response.close() response.close()
if response.status < 200 or response.status >= 300: if response.status < 200 or response.status >= 300:
......
...@@ -215,8 +215,9 @@ class S3FS(FS): ...@@ -215,8 +215,9 @@ class S3FS(FS):
tf.write(data) tf.write(data)
data = contents.read(524288) data = contents.read(524288)
tf.seek(0) tf.seek(0)
contents = tf key.set_contents_from_file(tf)
key.set_contents_from_file(contents) else:
key.set_contents_from_file(contents)
return self._sync_key(key) return self._sync_key(key)
def makepublic(self, path): def makepublic(self, path):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment