aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTad Fisher <tadfisher@gmail.com>2018-06-28 15:27:34 -0700
committerTad Fisher <tadfisher@gmail.com>2018-06-28 15:40:54 -0700
commitcb461eb752766c34cec422110239fbae4e1765fd (patch)
tree3ed0f5867964a09438ea1c0a9712f77c41c8bfcf
parent5d0cf801f21414a0f08cf593da914a5e6fc191ed (diff)
Tolerate base64 padding in secret
-rwxr-xr-xotp.bash2
-rwxr-xr-xtest/insert.t9
2 files changed, 10 insertions, 1 deletions
diff --git a/otp.bash b/otp.bash
index 2668d9a..55dbcb3 100755
--- a/otp.bash
+++ b/otp.bash
@@ -63,7 +63,7 @@ otp_parse_uri() {
local params
local IFS=\&; read -r -a params < <(echo "$p") ; unset IFS
- pattern='^(.+)=(.+)$'
+ pattern='^([^=]+)=(.+)$'
for param in "${params[@]}"; do
if [[ "$param" =~ $pattern ]]; then
case ${BASH_REMATCH[1]} in
diff --git a/test/insert.t b/test/insert.t
index 1c8ddb2..a8c6458 100755
--- a/test/insert.t
+++ b/test/insert.t
@@ -130,4 +130,13 @@ test_expect_success 'Insert from secret without passfile' '
echo [[ $("$PASS" show Example/alice@google.com) == "$uri" ]]
'
+test_expect_success 'Tolerates padding in secret' '
+ secret="JBSWY3DPEHPK3PXP=="
+ uri="otpauth://totp/Example:alice@google.com?secret=JBSWY3DPEHPK3PXP&issuer=Example"
+
+ test_pass_init &&
+ "$PASS" otp insert -s -i Example -a alice@google.com <<< "$secret" &&
+ echo [[ $("$PASS" show Example/alice@google.com) == "$uri" ]]
+'
+
test_done