Skip to content

Commit

Permalink
Merge pull request #406 from thibmeu/thibmeu/fix-age-plugin-read-line
Browse files Browse the repository at this point in the history
age: Replace callback input `read_line_initial_text` with `write_str` and `read_line`
  • Loading branch information
str4d authored Aug 7, 2023
2 parents ea42d81 + 634e567 commit 488212d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 7 additions & 0 deletions age/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ to 1.0.0 are beta releases.
- MSRV is now 1.65.0.
- Migrated to `base64 0.21`, `rsa 0.9`.

### Fixed
- `age::cli_common`:
- `UiCallbacks::confirm` no longer requires erasing the confirmation message
before it will accept a response.
- `UiCallbacks::request_public_string` no longer prepends the description to
the response string.

## [0.9.2] - 2023-06-12
### Added
- `age::Decryptor::{new_buffered, new_async_buffered}`, which are more efficient
Expand Down
8 changes: 4 additions & 4 deletions age/src/cli_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ fn confirm(query: &str, ok: &str, cancel: Option<&str>) -> pinentry::Result<bool
let term = console::Term::stderr();
let initial = format!("{}: (y/n) ", query);
loop {
let response = term.read_line_initial_text(&initial)?.to_lowercase();
term.write_str(&initial)?;
let response = term.read_line()?.to_lowercase();
if ["y", "yes"].contains(&response.as_str()) {
break Ok(true);
} else if ["n", "no"].contains(&response.as_str()) {
Expand Down Expand Up @@ -284,9 +285,8 @@ impl Callbacks for UiCallbacks {

fn request_public_string(&self, description: &str) -> Option<String> {
let term = console::Term::stderr();
term.read_line_initial_text(description)
.ok()
.filter(|s| !s.is_empty())
term.write_str(description).ok()?;
term.read_line().ok().filter(|s| !s.is_empty())
}

fn request_passphrase(&self, description: &str) -> Option<SecretString> {
Expand Down

0 comments on commit 488212d

Please sign in to comment.