diff options
author | rfkelly0 <rfkelly0@67cdc799-7952-0410-af00-57a81ceafa0f> | 2011-03-11 12:06:09 +0000 |
---|---|---|
committer | rfkelly0 <rfkelly0@67cdc799-7952-0410-af00-57a81ceafa0f> | 2011-03-11 12:06:09 +0000 |
commit | 8ed5d5d80663b7a8dddae27fe6ffde6ab8f8c9a8 (patch) | |
tree | afdf822c7c86cbba8d9bbf2b68eecfa94be319a6 /fs/contrib | |
parent | 86038e88093b904b5002ca52daa9b6bed25bc40b (diff) | |
download | pyfilesystem-git-8ed5d5d80663b7a8dddae27fe6ffde6ab8f8c9a8.tar.gz |
fix some malformed XML in DAVFS
Diffstat (limited to 'fs/contrib')
-rw-r--r-- | fs/contrib/davfs/__init__.py | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/fs/contrib/davfs/__init__.py b/fs/contrib/davfs/__init__.py index 04d2310..fe89ed9 100644 --- a/fs/contrib/davfs/__init__.py +++ b/fs/contrib/davfs/__init__.py @@ -166,7 +166,10 @@ class DAVFS(FS): """Convert a server-side URL into a client-side path.""" path = urlunquote(urlparse(url).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): """Check whether the given URL corresponds to the given local path.""" @@ -187,7 +190,7 @@ class DAVFS(FS): resp = self._raw_request(url,method,body,headers) # Loop to retry for redirects and authentication responses. while resp.status in (301,302,401,403): - resp.close() + #resp.close() if resp.status in (301,302,): visited.append(url) url = resp.getheader("Location",None) @@ -549,7 +552,7 @@ class DAVFS(FS): If the server is able to send responses in chunked encoding, then 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"}) try: if response.status == 404: @@ -670,9 +673,9 @@ class DAVFS(FS): (namespaceURI,localName) = self._split_xattr(name) # TODO: encode xml character entities in the namespace if namespaceURI: - pf = propfind(prop="<prop xmlns='"+namespaceURI+"'><"+localName+" /></prop>") + pf = propfind(prop="<D:prop xmlns:D='DAV:' xmlns='"+namespaceURI+"'><"+localName+" /></D:prop>") 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"}) try: if response.status != 207: @@ -706,7 +709,7 @@ class DAVFS(FS): else: p = "<%s>%s</%s>" % (localName,value,localName) 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.close() if response.status < 200 or response.status >= 300: @@ -720,7 +723,7 @@ class DAVFS(FS): else: p = "<%s />" % (localName,) 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.close() if response.status < 200 or response.status >= 300: |