]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
cli: decode all cli arguments, assuming that they are utf-8 encoded
authorZooko O'Whielacronx <zooko@zooko.com>
Tue, 23 Dec 2008 00:54:53 +0000 (17:54 -0700)
committerZooko O'Whielacronx <zooko@zooko.com>
Tue, 23 Dec 2008 00:54:53 +0000 (17:54 -0700)
Also encode all args to urllib as utf-8 because urllib doesn't handle unicode objects.
I'm not sure if it is appropriate to *assume* utf-8 encoding of cli args.  Perhaps the Right thing to do is to detect the platform encoding.  Any ideas?
This patch is mostly due to François Deppierraz.

src/allmydata/scripts/common.py
src/allmydata/scripts/runner.py

index a6d0a1099fdec7f37779f221802c4cdb3e45254c..fb404ce14d5787c09ca81d40a7391dc564743142 100644 (file)
@@ -129,4 +129,4 @@ def get_alias(aliases, path, default):
 
 def escape_path(path):
     segments = path.split("/")
-    return "/".join([urllib.quote(s) for s in segments])
+    return "/".join([urllib.quote(s.encode('utf-8')) for s in segments])
index 235cc2a072b9bb3704963dc5fe359d88cd97efa8..45a2c65b8c255329477bd56b3f42c329b162139c 100644 (file)
@@ -33,6 +33,12 @@ def runner(argv,
            stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr,
            install_node_control=True, additional_commands=None):
 
+    # Convert arguments to unicode
+    new_argv = []
+    for arg in argv:
+      new_argv.append(arg.decode('utf-8'))
+    argv = new_argv
+
     config = Options()
     if install_node_control:
         config.subCommands.extend(startstop_node.subCommands)