cli: use urllib.quote() on vdrive-path arguments before passing them through HTTP

This commit is contained in:
Zooko O'Whielacronx 2007-10-26 18:30:44 -07:00
parent 61d5899d66
commit 81e0820904
6 changed files with 7 additions and 5 deletions

View File

@ -7,7 +7,7 @@ def get(nodeurl, root_uri, vdrive_fname, local_file, stdout, stderr):
nodeurl += "/" nodeurl += "/"
url = nodeurl + "uri/%s/" % urllib.quote(root_uri.replace("/","!")) url = nodeurl + "uri/%s/" % urllib.quote(root_uri.replace("/","!"))
if vdrive_fname: if vdrive_fname:
url += vdrive_fname url += urllib.quote(vdrive_fname)
if local_file is None or local_file == "-": if local_file is None or local_file == "-":
outf = stdout outf = stdout

View File

@ -8,7 +8,7 @@ def list(nodeurl, root_uri, vdrive_pathname, stdout, stderr):
nodeurl += "/" nodeurl += "/"
url = nodeurl + "uri/%s/" % urllib.quote(root_uri.replace("/","!")) url = nodeurl + "uri/%s/" % urllib.quote(root_uri.replace("/","!"))
if vdrive_pathname: if vdrive_pathname:
url += vdrive_pathname url += urllib.quote(vdrive_pathname)
url += "?t=json" url += "?t=json"
data = urllib.urlopen(url).read() data = urllib.urlopen(url).read()

View File

@ -6,6 +6,8 @@ import simplejson
from allmydata.scripts.common_http import do_http from allmydata.scripts.common_http import do_http
def mv(nodeurl, root_uri, frompath, topath, stdout, stderr): def mv(nodeurl, root_uri, frompath, topath, stdout, stderr):
frompath = urllib.quote(frompath)
topath = urllib.quote(topath)
if nodeurl[-1] != "/": if nodeurl[-1] != "/":
nodeurl += "/" nodeurl += "/"
url = nodeurl + "uri/%s/" % urllib.quote(root_uri.replace("/","!")) url = nodeurl + "uri/%s/" % urllib.quote(root_uri.replace("/","!"))

View File

@ -24,7 +24,7 @@ def _put(serverurl, vdrive_fname, local_fname, verbosity):
url = "/vdrive/global/" url = "/vdrive/global/"
if vdrive_fname: if vdrive_fname:
url += vdrive_fname url += urllib.quote(vdrive_fname)
if local_fname is None or local_fname == "-": if local_fname is None or local_fname == "-":
infileobj = sys.stdin infileobj = sys.stdin

View File

@ -14,7 +14,7 @@ def put(nodeurl, root_uri, local_fname, vdrive_fname, verbosity,
nodeurl += "/" nodeurl += "/"
url = nodeurl + "uri/%s/" % urllib.quote(root_uri.replace("/","!")) url = nodeurl + "uri/%s/" % urllib.quote(root_uri.replace("/","!"))
if vdrive_fname: if vdrive_fname:
url += vdrive_fname url += urllib.quote(vdrive_fname)
infileobj = open(local_fname, "rb") infileobj = open(local_fname, "rb")
resp = do_http("PUT", url, infileobj) resp = do_http("PUT", url, infileobj)

View File

@ -13,7 +13,7 @@ def rm(nodeurl, root_uri, vdrive_pathname, verbosity, stdout, stderr):
nodeurl += "/" nodeurl += "/"
url = nodeurl + "uri/%s/" % urllib.quote(root_uri.replace("/","!")) url = nodeurl + "uri/%s/" % urllib.quote(root_uri.replace("/","!"))
if vdrive_pathname: if vdrive_pathname:
url += vdrive_pathname url += urllib.quote(vdrive_pathname)
resp = do_http("DELETE", url) resp = do_http("DELETE", url)