aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2013-11-10 20:38:46 -0200
committerSilvio Rhatto <rhatto@riseup.net>2013-11-10 20:38:46 -0200
commitd6ace9471fbeb4c6c57f803d870accd8b11c7d2f (patch)
treefcfa4e19ea8f93c48ef686d6f0d530f52a7cfa78
parentee1beb85b4dc8f7f0da9689c88706aeb516e954d (diff)
downloadkeyringer-d6ace9471fbeb4c6c57f803d870accd8b11c7d2f.tar.gz
keyringer-d6ace9471fbeb4c6c57f803d870accd8b11c7d2f.tar.bz2
Fixing encryption for files with spaces (closes #20)
-rwxr-xr-xlib/keyringer/actions/encrypt10
-rwxr-xr-xlib/keyringer/functions8
2 files changed, 11 insertions, 7 deletions
diff --git a/lib/keyringer/actions/encrypt b/lib/keyringer/actions/encrypt
index cc73b55..6b9c061 100755
--- a/lib/keyringer/actions/encrypt
+++ b/lib/keyringer/actions/encrypt
@@ -9,12 +9,12 @@ source "$LIB" || exit 1
# Aditional parameters
if [ ! -z "$3" ]; then
- UNENCRYPTED_FILE="$2"
- shift 2
- keyringer_get_new_file "$*"
+ shift 1
+ UNENCRYPTED_FILE="$*"
+ keyringer_get_new_file $*
if [ ! -f "$UNENCRYPTED_FILE" ]; then
- echo "Error: cannot encrypted $UNENCRYPTED_FILE: file not found."
+ echo "Error: cannot encrypt $UNENCRYPTED_FILE: file not found."
exit 1
fi
else
@@ -36,7 +36,7 @@ if [ "$BASENAME" == "encrypt" ]; then
fi
fi
-$GPG --use-agent --armor -e -s $(keyringer_recipients "$RECIPIENTS_FILE") --yes --output "$KEYDIR/$FILE" $UNENCRYPTED_FILE
+$GPG --use-agent --armor -e -s $(keyringer_recipients "$RECIPIENTS_FILE") --yes --output "$KEYDIR/$FILE" "$UNENCRYPTED_FILE"
err="$?"
diff --git a/lib/keyringer/functions b/lib/keyringer/functions
index 206e0da..67b5122 100755
--- a/lib/keyringer/functions
+++ b/lib/keyringer/functions
@@ -342,7 +342,6 @@ function keyringer_get_new_file {
# 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
@@ -350,8 +349,13 @@ function keyringer_get_new_file {
# Sanitize and complete file name
FILE="`echo $FILE | sed -e s/[^A-Za-z0-9.\/]/_/g`"
FILE="$(keyringer_filename "$FILE")"
+
+ # Warn user about file name change:w
+ if [ "`basename "$*"`" != "$FILE" ]; then
+ echo "Sanitizing destination filename to `basename $FILE`"
+ fi
- if [ -z "$FILE" ]; then
+ if [ -z "$*" ]; then
keyringer_action_usage
exit 1
fi