summaryrefslogtreecommitdiffstats
path: root/openpgp/src/parse/parse.rs
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2019-12-19 20:42:24 +0100
committerJustus Winter <justus@sequoia-pgp.org>2019-12-20 18:04:56 +0100
commitdb3d4cb1dd9251118418ced1a2d1690d0b6b344f (patch)
treeeb53ed339a4fea1a4cb7a871e78f940935dafe82 /openpgp/src/parse/parse.rs
parentb87a71dac7c1f1e2d0464bf0f86c009fe240dd4f (diff)
openpgp: Use Container for Literal, Unknown.
- Embed Container in Literal and Unknown. This reuses code. - More importantly, Literal and Unknown now correctly implement PartialEq. - Unknown cannot implement Ord. Remove PartialOrd as well, it seems like an obscure use case to order packets. - An unfortunate consequence of Unknown not implementing Eq is that Cert cannot, because it holds unknown packets. We consider that unacceptable. - See #93.
Diffstat (limited to 'openpgp/src/parse/parse.rs')
-rw-r--r--openpgp/src/parse/parse.rs13
1 files changed, 11 insertions, 2 deletions
diff --git a/openpgp/src/parse/parse.rs b/openpgp/src/parse/parse.rs
index 90f7264f..415eed3a 100644
--- a/openpgp/src/parse/parse.rs
+++ b/openpgp/src/parse/parse.rs
@@ -3693,6 +3693,10 @@ impl <'a> PacketParser<'a> {
let recursion_depth = self.recursion_depth();
+ // If there is no unread content left at this point, we want
+ // to preserve the content_was_read flag.
+ let content_was_read = self.content_was_read;
+
let unread_content = if self.state.settings.buffer_unread_content {
t!("({:?} at depth {}): buffering {} bytes of unread content",
self.packet.tag(), recursion_depth,
@@ -3704,7 +3708,12 @@ impl <'a> PacketParser<'a> {
self.packet.tag(), recursion_depth,
self.data_eof().unwrap().len());
- self.drop_eof()?
+ let dropped = self.drop_eof()?;
+ if ! dropped {
+ // Nothing was dropped, restore.
+ self.set_content_was_read(content_was_read);
+ }
+ dropped
};
if unread_content {
@@ -3923,7 +3932,7 @@ fn packet_parser_reader_interface() {
let (packet, ppr) = pp.recurse().unwrap();
assert!(ppr.is_none());
// Since we read all of the data, we expect content to be None.
- assert!(packet.body().is_none());
+ assert_eq!(packet.body().unwrap().len(), 0);
}
impl<'a> PacketParser<'a> {