user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH v2 3/5] pop3: TOP requests do not expire messages
Date: Wed, 20 Jul 2022 09:24:11 +0000	[thread overview]
Message-ID: <20220720092413.3309948-4-e@80x24.org> (raw)
In-Reply-To: <20220720092413.3309948-1-e@80x24.org>

RFC 2449 only documents "EXPIRE 0" behavior for RETR requests
which fetch the whole message.  TOP requests only fetch
the headers and top $N lines of the body, so it's probably
harmful for deletions to be triggered in those cases.
---
 lib/PublicInbox/POP3.pm |  3 ++-
 t/pop3d.t               | 11 ++++++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/lib/PublicInbox/POP3.pm b/lib/PublicInbox/POP3.pm
index 51c2b71a..2c20c84b 100644
--- a/lib/PublicInbox/POP3.pm
+++ b/lib/PublicInbox/POP3.pm
@@ -300,12 +300,13 @@ sub retr_cb { # called by git->cat_async via ibx_async_cat
 		$hdr .= "\r\n\r\n";
 		my @tmp = split(/^/m, $bdy);
 		$hdr .= join('', splice(@tmp, 0, $top_nr));
+	} elsif (exists $self->{expire}) {
+		$self->{expire} .= pack('S', $off + 1);
 	}
 	$$bref =~ s/^\./../gms;
 	$$bref .= substr($$bref, -2, 2) eq "\r\n" ? ".\r\n" : "\r\n.\r\n";
 	$self->msg_more("+OK message follows\r\n");
 	$self->write($bref);
-	$self->{expire} .= pack('S', $off + 1) if exists $self->{expire};
 	$self->requeue;
 }
 
diff --git a/t/pop3d.t b/t/pop3d.t
index d5ccb0d8..3d70935f 100644
--- a/t/pop3d.t
+++ b/t/pop3d.t
@@ -240,8 +240,17 @@ EOF
 	ok(defined($capa->{PIPELINING}), 'pipelining supported by CAPA');
 	is($capa->{EXPIRE}, 0, 'EXPIRE 0 set');
 
-	# clients which see "EXPIRE 0" can elide DELE requests
+	# ensure TOP doesn't trigger "EXPIRE 0" like RETR does (cf. RFC2449)
 	my $list = $oldc->list;
+	ok(scalar keys %$list, 'got a listing of messages');
+	ok($oldc->top($_, 1), "TOP $_ 1") for keys %$list;
+	ok($oldc->quit, 'QUIT after TOP');
+
+	# clients which see "EXPIRE 0" can elide DELE requests
+	$oldc = Net::POP3->new(@old_args);
+	ok($oldc->apop("$locked_mb.0", 'anonymous'), 'APOP for RETR');
+	is_deeply($oldc->capa, $capa, 'CAPA unchanged');
+	is_deeply($oldc->list, $list, 'LIST unchanged by previous TOP');
 	ok($oldc->get($_), "RETR $_") for keys %$list;
 	ok($oldc->quit, 'QUIT after RETR');
 

  parent reply	other threads:[~2022-07-20  9:24 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-19  2:49 [PATCH 0/2] preliminary POP3 daemon Eric Wong
2022-07-19  2:49 ` [PATCH 1/2] public-inbox-pop3d - a mostly read-only POP3 server Eric Wong
2022-07-19  2:49 ` [PATCH 2/2] pop3: implement IN-USE from RESP-CODES (RFC 2449) Eric Wong
2022-07-20  7:27 ` [PATCH 3/2] pop3: fix numerous bugs in delete handling Eric Wong
2022-07-20  9:24 ` [PATCH v2 0/5] public-inbox POP3 daemon Eric Wong
2022-07-20  9:24   ` [PATCH v2 1/5] public-inbox-pop3d - a mostly read-only POP3 server Eric Wong
2022-07-20  9:24   ` [PATCH v2 2/5] pop3: implement IN-USE from RESP-CODES (RFC 2449) Eric Wong
2022-07-20  9:24   ` Eric Wong [this message]
2022-07-20  9:24   ` [PATCH v2 4/5] netd: setup TLS bits for well-known STARTTLS ports Eric Wong
2022-07-20  9:24   ` [PATCH v2 5/5] pop3: advertise STLS in CAPA if appropriate Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220720092413.3309948-4-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).