From bdbf214658446e0821e67a5e58695df0881247b6 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sun, 29 Sep 2013 17:35:12 -0300 Subject: Sanitize file names (#20) --- lib/keyringer/functions | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'lib/keyringer/functions') 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 -- cgit v1.2.3