]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/IMAP.pm
imap: support out-of-bounds ranges
[public-inbox.git] / lib / PublicInbox / IMAP.pm
index 3815141a15ec399716b3e1fc58dbccd4d4636bb0..ffa76bb0266a0534b27e85c4f212e111cc611bdd 100644 (file)
@@ -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';
        }