aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLionel Flandrin <lfg@svkt.eu>2021-04-01 18:03:23 +0100
committerLionel Flandrin <lfg@svkt.eu>2021-04-01 18:15:20 +0100
commit0960f21fefa25befa7f671bee62f8ba22e0923ab (patch)
tree42edf47c5aebc0e67957687fec11a4cd6ca953c5
parent9e77724efff281f0fe6d05440ad65c5ab561f380 (diff)
downloadrbw-0960f21fefa25befa7f671bee62f8ba22e0923ab.tar.gz
rbw-0960f21fefa25befa7f671bee62f8ba22e0923ab.zip
Don't choke on empty passwords in the history
Fixes #50
-rw-r--r--src/api.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/api.rs b/src/api.rs
index 99e12fd..0ecc7fa 100644
--- a/src/api.rs
+++ b/src/api.rs
@@ -252,14 +252,18 @@ impl SyncResCipher {
let history = if let Some(history) = &self.password_history {
history
.iter()
- .map(|entry| crate::db::HistoryEntry {
- last_used_date: entry.last_used_date.clone(),
- password: entry.password.clone(),
+ .filter_map(|entry| {
+ // Gets rid of entries with a non-existent password
+ entry.password.clone().map(|p| crate::db::HistoryEntry {
+ last_used_date: entry.last_used_date.clone(),
+ password: p,
+ })
})
.collect()
} else {
vec![]
};
+
let (folder, folder_id) = if let Some(folder_id) = &self.folder_id {
let mut folder_name = None;
for folder in folders {
@@ -459,7 +463,7 @@ struct SyncResPasswordHistory {
#[serde(rename = "LastUsedDate")]
last_used_date: String,
#[serde(rename = "Password")]
- password: String,
+ password: Option<String>,
}
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)]