From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 148F11F619; Wed, 20 Jul 2022 09:24:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1658309054; bh=cslVtV5keJKaqvfyysXCxOwUNkYonEUdSELE+z1sVQ0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=UNuG6LDF9N8NJ1lE3F/uyGytuV3NmlnW4WPynqBdsvXDIjH6amYky/YL3W7RjVCOu UWBhH5WeKpIdyBttPdIl5KS7hlF3Fl+RDGGP18YpQ9QZIzOVVETsA3IurihUoyxW8M dn/O4Ih3XlgCer8gm5syorkzMGc9jGnlixL5Lv+A= From: Eric Wong 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 Message-Id: <20220720092413.3309948-4-e@80x24.org> In-Reply-To: <20220720092413.3309948-1-e@80x24.org> References: <20220720092413.3309948-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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');