diff options
-rw-r--r-- | openpgp/src/cert/parser/mod.rs | 21 | ||||
-rw-r--r-- | openpgp/tests/data/keys/bad-subkey-keyring.pgp | bin | 0 -> 18064 bytes |
2 files changed, 20 insertions, 1 deletions
diff --git a/openpgp/src/cert/parser/mod.rs b/openpgp/src/cert/parser/mod.rs index cc7bd6f5..560ff76d 100644 --- a/openpgp/src/cert/parser/mod.rs +++ b/openpgp/src/cert/parser/mod.rs @@ -782,9 +782,10 @@ impl<'a> CertParser<'a> { // // Returns the old state. Note: the packet iterator is preserved. fn reset(&mut self) -> Self { - // We need to preserve `source`. + // We need to preserve `source` and `filter`. let mut orig = mem::replace(self, Default::default()); self.source = orig.source.take(); + mem::swap(&mut self.filter, &mut orig.filter); orig } @@ -1029,6 +1030,8 @@ mod test { use crate::serialize::Serialize; use crate::types::DataFormat; + use crate::tests; + #[test] fn tokens() { use crate::cert::parser::low_level::lexer::{Token, Lexer}; @@ -1729,4 +1732,20 @@ mod test { Ok(()) } + + #[test] + fn filter() { + let fp = Fingerprint::from_hex( + "CBCD8F030588653EEDD7E2659B7DD433F254904A", + ).unwrap(); + + let cp = CertParser::from_bytes(tests::key("bad-subkey-keyring.pgp")) + .unwrap() + .unvalidated_cert_filter(|cert, _| { + cert.fingerprint() == fp + }); + let certs = cp.collect::<Result<Vec<Cert>>>().unwrap(); + assert_eq!(certs.len(), 1); + assert!(certs[0].fingerprint() == fp); + } } diff --git a/openpgp/tests/data/keys/bad-subkey-keyring.pgp b/openpgp/tests/data/keys/bad-subkey-keyring.pgp Binary files differnew file mode 100644 index 00000000..72acf4de --- /dev/null +++ b/openpgp/tests/data/keys/bad-subkey-keyring.pgp |