From 1d7064f0f9751290ea4113b77f9cc55cf1743ab5 Mon Sep 17 00:00:00 2001 From: Lionel Flandrin Date: Thu, 1 Apr 2021 18:12:08 +0100 Subject: Don't generate a password history entry for empty passwords Fixes #52 --- src/bin/rbw/commands.rs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/bin/rbw/commands.rs b/src/bin/rbw/commands.rs index 2da06a2..1ceb409 100644 --- a/src/bin/rbw/commands.rs +++ b/src/bin/rbw/commands.rs @@ -850,14 +850,20 @@ pub fn edit( } => (username, password, uris, totp), _ => unreachable!(), }; - let new_history_entry = rbw::db::HistoryEntry { - last_used_date: format!( - "{}", - humantime::format_rfc3339(std::time::SystemTime::now()) - ), - password: entry_password.clone().unwrap_or_else(String::new), - }; - history.insert(0, new_history_entry); + + if let Some(prev_password) = entry_password.clone() { + let new_history_entry = rbw::db::HistoryEntry { + last_used_date: format!( + "{}", + humantime::format_rfc3339( + std::time::SystemTime::now() + ) + ), + password: prev_password, + }; + history.insert(0, new_history_entry); + } + let data = rbw::db::EntryData::Login { username: entry_username.clone(), password, -- cgit v1.2.3