diff options
author | Robin Krahl <robin.krahl@ireas.org> | 2018-12-19 19:33:50 +0000 |
---|---|---|
committer | Daniel Müller <d-e-s-o@users.noreply.github.com> | 2018-12-19 20:11:33 -0800 |
commit | 170e1df9d96f628af8cf8107f29227b90ae9350b (patch) | |
tree | 337ead190bfc5ff61cd8cf413e2d7163748b525a | |
parent | 74d9302eeddc0c9aadd9a8d6ebcb786d55a91320 (diff) | |
download | nitrocli-170e1df9d96f628af8cf8107f29227b90ae9350b.tar.gz nitrocli-170e1df9d96f628af8cf8107f29227b90ae9350b.tar.bz2 |
pinentry: Encode spaces in prompt argument
Spaces in the arguments for gpg-connect-agent’s `GET_PASSPHRASE` command
have to be esaced using a plus sign. Somehow this was missing for the
prompt argument. This patch adds escaping for the prompt so that the
pinentry dialog is displayed correctly.
-rw-r--r-- | nitrocli/CHANGELOG.md | 2 | ||||
-rw-r--r-- | nitrocli/src/pinentry.rs | 4 |
2 files changed, 4 insertions, 2 deletions
diff --git a/nitrocli/CHANGELOG.md b/nitrocli/CHANGELOG.md index 6eda412..81102a9 100644 --- a/nitrocli/CHANGELOG.md +++ b/nitrocli/CHANGELOG.md @@ -10,6 +10,8 @@ Unreleased and building of the project - Added badges indicating pipeline status, current `crates.io` published version of the crate, and minimum version of `rustc` required +- Fixed wrong messages in the pinentry dialog that were caused by unescaped + spaces in a string 0.1.3 diff --git a/nitrocli/src/pinentry.rs b/nitrocli/src/pinentry.rs index fc7af2c..ce9a98f 100644 --- a/nitrocli/src/pinentry.rs +++ b/nitrocli/src/pinentry.rs @@ -90,10 +90,10 @@ pub fn inquire_passphrase(pin_type: PinType, error_msg: Option<&str>) -> Result< let error_msg = error_msg .map(|msg| msg.replace(" ", "+")) .unwrap_or_else(|| String::from("+")); - let prompt = pin_type.prompt(); + let prompt = pin_type.prompt().replace(" ", "+"); let description = pin_type.description().replace(" ", "+"); - let args = vec![cache_id, &error_msg, prompt, &description].join(" "); + let args = vec![cache_id, &error_msg, &prompt, &description].join(" "); let command = "GET_PASSPHRASE --data ".to_string() + &args; // We could also use the --data parameter here to have a more direct // representation of the passphrase but the resulting response was |