aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2013-09-29 17:35:12 -0300
committerSilvio Rhatto <rhatto@riseup.net>2013-09-29 17:35:12 -0300
commitbdbf214658446e0821e67a5e58695df0881247b6 (patch)
tree3d848ce0b2c368f62b7b48844a3af6b802da6f3e /lib
parent1145393c5405187b50600f65371fb49c376c0c4f (diff)
downloadkeyringer-bdbf214658446e0821e67a5e58695df0881247b6.tar.gz
keyringer-bdbf214658446e0821e67a5e58695df0881247b6.tar.bz2
Sanitize file names (#20)
Diffstat (limited to 'lib')
-rwxr-xr-xlib/keyringer/functions12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/keyringer/functions b/lib/keyringer/functions
index 1bc6393..37a33aa 100755
--- a/lib/keyringer/functions
+++ b/lib/keyringer/functions
@@ -333,7 +333,17 @@ function keyringer_get_file {
# Get a new file argument
function keyringer_get_new_file {
- FILE="$(keyringer_filename "$1")"
+ # File must not contain spaces
+ if [ ! -z "$2" ] ; then
+ FILE="`echo "$*" | sed -e 's/ /_/g'`"
+ echo "File $* has spaces, secret will be named as $FILE..."
+ else
+ FILE="$1"
+ fi
+
+ # Sanitize and complete file name
+ FILE="`echo $FILE | sed -e s/[^A-Za-z0-9.]/_/g`"
+ FILE="$(keyringer_filename "$FILE")"
if [ -z "$FILE" ]; then
keyringer_action_usage