aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xpinentry-rofi.sh11
-rw-r--r--tests/foundational.bats15
2 files changed, 23 insertions, 3 deletions
diff --git a/pinentry-rofi.sh b/pinentry-rofi.sh
index 7f01b2e..2695a88 100755
--- a/pinentry-rofi.sh
+++ b/pinentry-rofi.sh
@@ -70,7 +70,7 @@ rawurlencode() {
esac
encoded+="${o}"
done
- printf "%s" "${encoded}" # You can either set a return variable (FASTER)
+ printf "%s" "${encoded}" # You can either set a return variable (FASTER)
}
rawurldecode() {
@@ -81,6 +81,11 @@ rawurldecode() {
printf '%b' "${1//%/\\x}"
}
+# Except Assuan apparently doesn't want really encoded strings, but some kind of bastard
+basturldecode () {
+ echo "$1" | sed -e 's/</\&lt;/g' -e 's/>/\&gt;/g'
+}
+
rofi_cmd="rofi -dmenu -input /dev/null -password"
INSIDE_BATS=${INSIDE_BATS:-0}
@@ -164,7 +169,7 @@ while : ; do
#SETDESC Please enter the passphrase for the ssh key%0A ke:yf:in:ge:rp:ri:nt
IFS=" " line_arr=($(split_line "$line"))
log_debug "line_arr: ${line_arr[*]}"
- temp_str="$(rawurldecode "${line_arr[*]}")"
+ temp_str="$(basturldecode "${line_arr[*]}")"
log_debug "temp_str: ${temp_str}"
win_mesg="$(rawurlencode "${temp_str}")"
assuan_send "OK"
@@ -178,7 +183,7 @@ while : ; do
IFS=" " line_arr=($(split_line "$line"))
log_debug "line_arr: ${line_arr[*]}"
log_debug "line_arr: ${line_arr[*]}"
- temp_str="$(rawurldecode "${line_arr[*]}")"
+ temp_str="$(basturldecode "${line_arr[*]}")"
log_debug "temp_str: ${temp_str}"
win_title="$(rawurlencode "${temp_str}")"
assuan_send "OK"
diff --git a/tests/foundational.bats b/tests/foundational.bats
index 2d53b10..458b43f 100644
--- a/tests/foundational.bats
+++ b/tests/foundational.bats
@@ -49,6 +49,21 @@ created 2016-04-27 (main key ID 79205802880BC9D8)."
[[ "$observed" == "$expected" ]] || diff -u <(echo -e "$observed") <(echo -e "$expected")
}
+@test "decode bastardized URL encoded string" {
+ local expected
+ mapfile -d '' expected <<- EOF
+ Please enter the passphrase to unlock the OpenPGP secret key:
+ "Matěj Cepl &lt;mcepl@cepl.eu&gt;"
+ 4096-bit RSA key, ID 77D15A36BD4211B2,
+ created 2016-04-27 (main key ID 79205802880BC9D8).
+ EOF
+ log_debug "expected: ${expected}"
+ log_debug "instr: ${instr}"
+ observed=$(basturldecode "${instr}")
+ log_debug "observed: ${observed}"
+ [[ "$observed" == "$expected" ]] || diff -u <(echo "$observed") <(printf "%s" "$expected")
+}
+
@test "encode into RFC-3986 encoded string" {
local expected