fix #538 -- don't crash on wrong setup codes for ac-message, don't use "expect(), added test

This commit is contained in:
holger krekel
2019-09-18 16:16:46 +02:00
parent dc8a2f54e5
commit cee0e22ce7
3 changed files with 15 additions and 5 deletions

View File

@@ -289,10 +289,11 @@ pub fn dc_pgp_symm_decrypt(passphrase: &str, ctext: &[u8]) -> Option<Vec<u8>> {
enc_msg
.and_then(|msg| {
let mut decryptor = msg
.decrypt_with_password(|| passphrase.into())
.expect("failed decryption");
decryptor.next().expect("no message")
let mut decryptor = msg.decrypt_with_password(|| passphrase.into())?;
match decryptor.next() {
Some(x) => x,
None => Err(pgp::errors::Error::InvalidInput),
}
})
.and_then(|msg| msg.get_content())
.ok()