mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-03-11 14:53:55 +00:00
tahoe_cp.py: Don't call urllib.quote with an Unicode argument, fix #1224
tahoe_backup.py: Fix another (potential) occurrence of calling urllib.quote() with an Unicode parameter
This commit is contained in:
parent
c18953c169
commit
14ee763c54
@ -50,7 +50,7 @@ def mkdir(contents, options):
|
|||||||
|
|
||||||
def put_child(dirurl, childname, childcap):
|
def put_child(dirurl, childname, childcap):
|
||||||
assert dirurl[-1] == "/"
|
assert dirurl[-1] == "/"
|
||||||
url = dirurl + urllib.quote(childname) + "?t=uri"
|
url = dirurl + urllib.quote(unicode_to_url(childname)) + "?t=uri"
|
||||||
resp = do_http("PUT", url, childcap)
|
resp = do_http("PUT", url, childcap)
|
||||||
if resp.status not in (200, 201):
|
if resp.status not in (200, 201):
|
||||||
raise HTTPError("Error during put_child", resp)
|
raise HTTPError("Error during put_child", resp)
|
||||||
|
@ -51,7 +51,7 @@ def mkdir(targeturl):
|
|||||||
def make_tahoe_subdirectory(nodeurl, parent_writecap, name):
|
def make_tahoe_subdirectory(nodeurl, parent_writecap, name):
|
||||||
url = nodeurl + "/".join(["uri",
|
url = nodeurl + "/".join(["uri",
|
||||||
urllib.quote(parent_writecap),
|
urllib.quote(parent_writecap),
|
||||||
urllib.quote(name),
|
urllib.quote(unicode_to_url(name)),
|
||||||
]) + "?t=mkdir"
|
]) + "?t=mkdir"
|
||||||
resp = do_http("POST", url)
|
resp = do_http("POST", url)
|
||||||
if resp.status in (200, 201):
|
if resp.status in (200, 201):
|
||||||
|
@ -1487,6 +1487,39 @@ class Cp(GridTestMixin, CLITestMixin, unittest.TestCase):
|
|||||||
d.addCallback(_check)
|
d.addCallback(_check)
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
def test_unicode_dirnames(self):
|
||||||
|
self.basedir = "cli/Cp/unicode_dirnames"
|
||||||
|
|
||||||
|
fn1 = os.path.join(unicode(self.basedir), u"\u00C4rtonwall")
|
||||||
|
try:
|
||||||
|
fn1_arg = fn1.encode(get_argv_encoding())
|
||||||
|
artonwall_arg = u"\u00C4rtonwall".encode(get_argv_encoding())
|
||||||
|
except UnicodeEncodeError:
|
||||||
|
raise unittest.SkipTest("A non-ASCII command argument could not be encoded on this platform.")
|
||||||
|
|
||||||
|
self.skip_if_cannot_represent_filename(fn1)
|
||||||
|
|
||||||
|
self.set_up_grid()
|
||||||
|
|
||||||
|
d = self.do_cli("create-alias", "tahoe")
|
||||||
|
d.addCallback(lambda res: self.do_cli("mkdir", "tahoe:test/" + artonwall_arg))
|
||||||
|
d.addCallback(lambda res: self.do_cli("cp", "-r", "tahoe:test", "tahoe:test2"))
|
||||||
|
d.addCallback(lambda res: self.do_cli("ls", "tahoe:test2"))
|
||||||
|
def _check((rc, out, err)):
|
||||||
|
try:
|
||||||
|
unicode_to_output(u"\u00C4rtonwall")
|
||||||
|
except UnicodeEncodeError:
|
||||||
|
self.failUnlessReallyEqual(rc, 1)
|
||||||
|
self.failUnlessReallyEqual(out, "")
|
||||||
|
self.failUnlessIn(quote_output(u"\u00C4rtonwall"), err)
|
||||||
|
self.failUnlessIn("files whose names could not be converted", err)
|
||||||
|
else:
|
||||||
|
self.failUnlessReallyEqual(rc, 0)
|
||||||
|
self.failUnlessReallyEqual(out.decode(get_output_encoding()), u"\u00C4rtonwall\n")
|
||||||
|
self.failUnlessReallyEqual(err, "")
|
||||||
|
d.addCallback(_check)
|
||||||
|
|
||||||
|
return d
|
||||||
|
|
||||||
class Backup(GridTestMixin, CLITestMixin, StallMixin, unittest.TestCase):
|
class Backup(GridTestMixin, CLITestMixin, StallMixin, unittest.TestCase):
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user