Browse code

unicodise gpg_encrypt/decrypt info/debug output

Otherwise it crashes UnicodeError fed non-ASCII filenames.

Matt Domsch authored on 2014/04/26 08:52:28
Showing 1 changed files
... ...
@@ -1672,7 +1672,7 @@ def gpg_encrypt(filename):
1672 1672
         "input_file" : filename,
1673 1673
         "output_file" : tmp_filename,
1674 1674
     }
1675
-    info(u"Encrypting file %(input_file)s to %(output_file)s..." % args)
1675
+    info(u"Encrypting file %s to %s..." % (unicodise(filename), tmp_filename))
1676 1676
     command = resolve_list(cfg.gpg_encrypt.split(" "), args)
1677 1677
     code = gpg_command(command, cfg.gpg_passphrase)
1678 1678
     return (code, tmp_filename, "gpg")
... ...
@@ -1685,11 +1685,11 @@ def gpg_decrypt(filename, gpgenc_header = "", in_place = True):
1685 1685
         "input_file" : filename,
1686 1686
         "output_file" : tmp_filename,
1687 1687
     }
1688
-    info(u"Decrypting file %(input_file)s to %(output_file)s..." % args)
1688
+    info(u"Decrypting file %s to %s..." % (unicodise(filename), tmp_filename))
1689 1689
     command = resolve_list(cfg.gpg_decrypt.split(" "), args)
1690 1690
     code = gpg_command(command, cfg.gpg_passphrase)
1691 1691
     if code == 0 and in_place:
1692
-        debug(u"Renaming %s to %s" % (tmp_filename, filename))
1692
+        debug(u"Renaming %s to %s" % (tmp_filename, unicodise(filename)))
1693 1693
         os.unlink(filename)
1694 1694
         os.rename(tmp_filename, filename)
1695 1695
         tmp_filename = filename