aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem@fripost.org>2015-03-19 23:34:11 +0100
committerGuilhem Moulin <guilhem@fripost.org>2015-03-19 23:34:14 +0100
commitcc9fda4d36f3ae5427fa05564a4bdd5b53e94ce5 (patch)
tree2399ca60108544a618a646d350bc6f37741e048b
parent867c4d4095f9bdb2ad1e6f283ff66827e5199d86 (diff)
Fix potential issue when filling placeholders.
(e.g., if $h contains '%i' we don't want to fill it again; '%%s' should expand to '%s' not '$s')
-rwxr-xr-xicevault8
1 files changed, 5 insertions, 3 deletions
diff --git a/icevault b/icevault
index 07a03a8..40eaf4b 100755
--- a/icevault
+++ b/icevault
@@ -256,9 +256,11 @@ sub getIdentityFile($) {
my ($s, $h, $i) = ($1, $2, $3);
my $file = $CONFIG{store};
- $file =~ s/%s/$s/g;
- $file =~ s/%h/$h/g;
- $file =~ s/%i/$i/g;
+ $file =~ s{\%(.)}{ $1 eq '%' ? '%' :
+ $1 eq 's' ? $s :
+ $1 eq 'h' ? $h :
+ $1 eq 'i' ? $i :
+ die "Invalid placeholder %$1" }ge;
return $file;
}