amnong / easywebdav

A WebDAV Client in Python
http://pypi.python.org/pypi/easywebdav/
ISC License
207 stars 113 forks source link

Fix url if WebDav path containing not escaped characters #35

Open ffoxin opened 9 years ago

ffoxin commented 9 years ago

It is necessary to escape WebDav path before requesting it.

Server path can contain some charaters that should be escaped in url (i.e. space character).

hashbackup commented 6 years ago

I believe two other spots need this:

@@ -83,7 +84,7 @@
             port = 443 if protocol == 'https' else 80
         self.baseurl = '{0}://{1}:{2}'.format(protocol, host, port)
         if path:
-            self.baseurl = '{0}/{1}'.format(self.baseurl, path)
+            self.baseurl = '{0}/{1}'.format(self.baseurl, quote(path))
         self.cwd = '/'
         self.session = requests.session()
         self.session.verify = verify_ssl
@@ -114,10 +115,10 @@
         return response

     def _get_url(self, path):
-        path = str(path).strip()
+        path = quote(str(path).strip())
         if path.startswith('/'):
             return self.baseurl + path
-        return "".join((self.baseurl, self.cwd, path))
+        return "".join((self.baseurl, quote(self.cwd), path))