]> Sergey Matveev's repositories - public-inbox.git/commitdiff
imap: fix uninitialized var on MSN search miss
authorEric Wong <e@80x24.org>
Tue, 5 Jan 2021 18:19:48 +0000 (18:19 +0000)
committerEric Wong <e@80x24.org>
Tue, 5 Jan 2021 22:46:22 +0000 (22:46 +0000)
It seems only triggered by bots trying to steal information.

lib/PublicInbox/IMAP.pm
t/imapd.t

index 68a7e050a27f8928cd58711a0f612bbd131c2b3b..226e98a2e2a144930d221fe798d663ab3feb78ad 100644 (file)
@@ -1142,7 +1142,7 @@ sub search_common {
                };
                my $mset = $srch->mset($q, $opt);
                my $uids = $srch->mset_to_artnums($mset, $opt);
-               msn_convert($self, $uids) if $want_msn;
+               msn_convert($self, $uids) if scalar(@$uids) && $want_msn;
                "* SEARCH @$uids\r\n$tag OK Search done\r\n";
        } else {
                "$tag BAD Error\r\n";
index 5d610dfdedd733b02625754a9612bb07193ef6c0..1df9d26e5dea9190a51c034978795ba4bf1a8901 100644 (file)
--- a/t/imapd.t
+++ b/t/imapd.t
@@ -371,11 +371,13 @@ is(scalar keys %$ret, 3, 'got all 3 messages');
 
 SKIP: {
        # do any clients use non-UID IMAP SEARCH?
-       skip 'Xapian missing', 2 if $level eq 'basic';
+       skip 'Xapian missing', 3 if $level eq 'basic';
        my $x = $mic->search('all');
        is_deeply($x, [1, 2, 3], 'MSN SEARCH works before rm');
        $x = $mic->search(qw(header subject embedded));
        is_deeply($x, [2], 'MSN SEARCH on Subject works before rm');
+       $x = $mic->search('FROM scraper@example.com');
+       is_deeply($x, [], "MSN SEARCH miss won't trigger warnings");
 }
 
 {