diff options
author | Justus Winter <4winter@informatik.uni-hamburg.de> | 2011-09-22 11:38:03 +0200 |
---|---|---|
committer | Justus Winter <4winter@informatik.uni-hamburg.de> | 2011-09-22 11:57:08 +0200 |
commit | 4c33283363606079f2cd27a376d2fd012b157f76 (patch) | |
tree | 0da9874e5e8b1ac05b14244f3a1fe544241e7dbf /alot | |
parent | 661c4f255f86e9ac56eea0cf7e37b51b4d94ac2a (diff) |
Add shell_quote to helper
shell_quote securely quotes strings being used as command line arguments.
Diffstat (limited to 'alot')
-rw-r--r-- | alot/helper.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/alot/helper.py b/alot/helper.py index d20ba844..d7916123 100644 --- a/alot/helper.py +++ b/alot/helper.py @@ -113,3 +113,12 @@ def attach(path, mail, filename=None): part.add_header('Content-Disposition', 'attachment', filename=filename) mail.attach(part) + +def shell_quote(text): + r''' + >>> print(shell_quote("hello")) + 'hello' + >>> print(shell_quote("hello'there")) + 'hello'"'"'there' + ''' + return "'%s'" % text.replace("'", """'"'"'""") |