From: Eric Wong Date: Wed, 23 Oct 2024 09:30:05 +0000 (+0000) Subject: imap: allow bare `*' in range X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=927993e58602e5b35c0647701984d3fad20640cf;p=thirdparty%2Fpublic-inbox.git imap: allow bare `*' in range I missed that a bare `*' is an allowable seq-number for IMAP for the number of the latest message in a given mailbox. Reported-by: Augusto Stoffel Link: https://public-inbox.org/meta/87jzdzguml.fsf@gmail.com/ --- diff --git a/lib/PublicInbox/IMAP.pm b/lib/PublicInbox/IMAP.pm index 378a0363e..742497841 100644 --- a/lib/PublicInbox/IMAP.pm +++ b/lib/PublicInbox/IMAP.pm @@ -88,7 +88,7 @@ for my $att (keys %FETCH_ATT) { } undef %FETCH_NEED; -my $valid_range = '[0-9]+|[0-9]+:[0-9]+|[0-9]+:\*'; +my $valid_range = '[0-9]+|[0-9]+:[0-9]+|[0-9]+:\*|\*'; $valid_range = qr/\A(?:$valid_range)(?:,(?:$valid_range))*\z/; sub do_greet { @@ -697,6 +697,9 @@ sub range_step ($$) { # just let the caller do an out-of-range query if a single # UID is out-of-range ++$beg if ($beg <= $uid_base || $end > $uid_end); + } elsif ($range eq '*') { + $beg = $end = $self->{ibx}->over(1)->max; + uid_clamp($self, \$beg, \$end); } else { return 'BAD fetch range'; } diff --git a/t/imapd.t b/t/imapd.t index 549b87666..27c46e540 100644 --- a/t/imapd.t +++ b/t/imapd.t @@ -174,7 +174,7 @@ is_deeply(scalar $mic->flags('1'), [], '->flags works'); is_deeply($ret, {}, "out-of-range UID FETCH $r"); } -for my $r ('1:*', '1') { +for my $r ('1:*', '1', '*') { $ret = $mic->fetch_hash($r, 'RFC822') or BAIL_OUT "FETCH $@"; is_deeply([keys %$ret], [1]); like($ret->{1}->{RFC822}, qr/\r\n\r\nThis is a test/, 'read full');