fix: Reject empty string field value
All checks were successful
Rust CI / Rust CI (pull_request) Successful in 2m3s
Write changelog / write-changelog (push) Successful in 4s
Rust CI / Rust CI (push) Successful in 1m58s

Signed-off-by: Awiteb <a@4rs.nl>
This commit is contained in:
Awiteb 2024-07-24 11:03:42 +03:00
parent 6e5e3c093c
commit 6f5ca5f452
Signed by: awiteb
GPG key ID: 3F6B55640AA6682F
2 changed files with 25 additions and 0 deletions

View file

@ -92,6 +92,29 @@ impl LprsCommand for Add {
))); )));
} }
} }
if self
.password
.as_ref()
.is_some_and(|p| p.as_ref().is_some_and(|p| p.is_empty()))
|| self.vault_info.name.is_empty()
|| self
.vault_info
.username
.as_ref()
.is_some_and(|u| u.is_empty())
|| self
.vault_info
.service
.as_ref()
.is_some_and(|s| s.is_empty())
|| self.vault_info.note.as_ref().is_some_and(|n| n.is_empty())
|| self
.custom_fields
.iter()
.any(|(k, v)| k.is_empty() || v.is_empty())
{
return Err(LprsError::EmptyValue);
}
if self if self
.custom_fields .custom_fields
.iter() .iter()

View file

@ -44,6 +44,8 @@ pub enum Error {
custom fields {0}" custom fields {0}"
)] )]
ReservedPrefix(&'static str), ReservedPrefix(&'static str),
#[error("Invalid Field Value: Field value cannot be empty")]
EmptyValue,
#[error("Base32 Error: {0}")] #[error("Base32 Error: {0}")]
Base32(String), Base32(String),
#[error("{0}")] #[error("{0}")]