Merge branch 'master' into develop
This commit is contained in:
commit
c238c281dd
1 changed files with 6 additions and 3 deletions
|
@ -16,10 +16,10 @@ from webdav3.exceptions import *
|
||||||
from webdav3.urn import Urn
|
from webdav3.urn import Urn
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from urllib.parse import unquote, urlsplit
|
from urllib.parse import unquote, urlsplit, urlparse
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from urllib import unquote
|
from urllib import unquote
|
||||||
from urlparse import urlsplit
|
from urlparse import urlsplit, urlparse
|
||||||
|
|
||||||
__version__ = "0.2"
|
__version__ = "0.2"
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
@ -958,12 +958,12 @@ class WebDavXmlUtils:
|
||||||
:param hostname: the server hostname.
|
:param hostname: the server hostname.
|
||||||
:return: XML object of response for the remote resource defined by path.
|
:return: XML object of response for the remote resource defined by path.
|
||||||
"""
|
"""
|
||||||
|
prefix = urlparse(hostname).path
|
||||||
try:
|
try:
|
||||||
if isinstance(content, str):
|
if isinstance(content, str):
|
||||||
content = content.encode('utf-8')
|
content = content.encode('utf-8')
|
||||||
tree = etree.fromstring(content)
|
tree = etree.fromstring(content)
|
||||||
responses = tree.findall("{DAV:}response")
|
responses = tree.findall("{DAV:}response")
|
||||||
|
|
||||||
n_path = Urn.normalize_path(path)
|
n_path = Urn.normalize_path(path)
|
||||||
|
|
||||||
for resp in responses:
|
for resp in responses:
|
||||||
|
@ -971,6 +971,9 @@ class WebDavXmlUtils:
|
||||||
|
|
||||||
if Urn.compare_path(n_path, href) is True:
|
if Urn.compare_path(n_path, href) is True:
|
||||||
return resp
|
return resp
|
||||||
|
href_without_prefix = href[len(prefix):] if href.startswith(prefix) else href
|
||||||
|
if Urn.compare_path(n_path, href_without_prefix) is True:
|
||||||
|
return resp
|
||||||
raise RemoteResourceNotFound(path)
|
raise RemoteResourceNotFound(path)
|
||||||
except etree.XMLSyntaxError:
|
except etree.XMLSyntaxError:
|
||||||
raise MethodNotSupported(name="is_dir", server=hostname)
|
raise MethodNotSupported(name="is_dir", server=hostname)
|
||||||
|
|
Loading…
Add table
Reference in a new issue