From af73b745613b8db3090823f563fe54a05748b810 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sun, 24 May 2020 13:32:00 -0400 Subject: handle uri entries with no uri set apparently this can happen if you create the uri entry but then delete the contents of the uri afterward? probably also in other edge case scenarios --- src/api.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/api.rs b/src/api.rs index c0125d6..d531836 100644 --- a/src/api.rs +++ b/src/api.rs @@ -138,7 +138,11 @@ impl SyncResCipher { password: login.password.clone(), uris: login.uris.as_ref().map_or_else( || vec![], - |uris| uris.iter().map(|uri| uri.uri.clone()).collect(), + |uris| { + uris.iter() + .filter_map(|uri| uri.uri.clone()) + .collect() + }, ), } } else if let Some(card) = &self.card { @@ -227,7 +231,7 @@ struct CipherLogin { #[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] struct CipherLoginUri { #[serde(rename = "Uri")] - uri: String, + uri: Option, } #[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] @@ -515,7 +519,9 @@ impl Client { } else { Some( uris.iter() - .map(|s| CipherLoginUri { uri: s.to_string() }) + .map(|s| CipherLoginUri { + uri: Some(s.to_string()), + }) .collect(), ) }; @@ -643,7 +649,9 @@ impl Client { } else { Some( uris.iter() - .map(|s| CipherLoginUri { uri: s.to_string() }) + .map(|s| CipherLoginUri { + uri: Some(s.to_string()), + }) .collect(), ) }; -- cgit v1.2.3-54-g00ecf