Skip to content
19 changes: 14 additions & 5 deletions webdav/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def parse(response):
urns = parse(response)

path = "{root}{path}".format(root=self.webdav.root, path=directory_urn.path())
return [urn.filename() for urn in urns if urn.path() != path and urn.path() != path[:-1]]
return [urn.filename() for urn in urns if urn.path() != unquote(path) and urn.path() != unquote(path[:-1])]

except pycurl.error:
raise NotConnection(self.webdav.hostname)
Expand Down Expand Up @@ -751,7 +751,8 @@ def parse(response, path):
'created': ".//{DAV:}creationdate",
'name': ".//{DAV:}displayname",
'size': ".//{DAV:}getcontentlength",
'modified': ".//{DAV:}getlastmodified"
'modified': ".//{DAV:}getlastmodified",
'etag': ".//{DAV:}getetag"
}

resps = tree.findall("{DAV:}response")
Expand All @@ -765,13 +766,19 @@ def parse(response, path):
continue
else:
path_with_sep = "{path}{sep}".format(path=path, sep=Urn.separate)
if not path == urn and not path_with_sep == urn:
path_unquoted = unquote(path)
if not path == urn and not path_with_sep == urn and not path_unquoted == urn:
continue

info = dict()
for (name, value) in find_attributes.items():
info[name] = resp.findtext(value)
return info

try:
info['etag'] = info['etag'][1:-1] # remove quotes from etag
except KeyError:
pass

raise RemoteResourceNotFound(path)
except etree.XMLSyntaxError:
Expand Down Expand Up @@ -800,7 +807,7 @@ def parse(response, path):

path = "{root}{path}".format(root=self.webdav.root, path=urn.path())

return parse(response, path)
return parse(response, unquote(path))

except pycurl.error:
raise NotConnection(self.webdav.hostname)
Expand All @@ -824,7 +831,9 @@ def parse(response, path):
continue
else:
path_with_sep = "{path}{sep}".format(path=path, sep=Urn.separate)
if not path == urn and not path_with_sep == urn:
path_unquoted = unquote(path)

if not path == urn and not path_with_sep == urn and not path_unquoted == urn:
continue
type = resp.find(".//{DAV:}resourcetype")
if type is None:
Expand Down