about summary refs log tree commit homepage
path: root/lib/PublicInbox/IMAP.pm
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-06-10 07:04:35 +0000
committerEric Wong <e@yhbt.net>2020-06-13 07:55:45 +0000
commitdaa98292c95a403975fb4906088c160758b15106 (patch)
tree8e31c89efd350b23b03070f87751c902b31dc403 /lib/PublicInbox/IMAP.pm
parent94245dfc85576b5981b23fc5c917189b5fbbe3e8 (diff)
downloadpublic-inbox-daa98292c95a403975fb4906088c160758b15106.tar.gz
"$UID_START:*" needs to return at least one message according
to RFC 3501 section 6.4.8.

While we're in the area, coerce ranges to (unsigned) integers by
adding zero ("+ 0") to reduce memory overhead.
Diffstat (limited to 'lib/PublicInbox/IMAP.pm')
-rw-r--r--lib/PublicInbox/IMAP.pm8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/PublicInbox/IMAP.pm b/lib/PublicInbox/IMAP.pm
index 3815141a..ffa76bb0 100644
--- a/lib/PublicInbox/IMAP.pm
+++ b/lib/PublicInbox/IMAP.pm
@@ -455,11 +455,13 @@ sub range_step ($$) {
                 $$range_csv = undef;
         }
         if ($range =~ /\A([0-9]+):([0-9]+)\z/) {
-                ($beg, $end) = ($1, $2);
+                ($beg, $end) = ($1 + 0, $2 + 0);
         } elsif ($range =~ /\A([0-9]+):\*\z/) {
-                ($beg, $end) =  ($1, $ibx->mm->max // 0);
+                $beg = $1 + 0;
+                $end = $ibx->mm->max // 0;
+                $beg = $end if $beg > $end;
         } elsif ($range =~ /\A[0-9]+\z/) {
-                $beg = $end = $range;
+                $beg = $end = $range + 0;
         } else {
                 return 'BAD fetch range';
         }