]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei ls-mail-sync: fix handling of non-wildcard filters
authorEric Wong <e@80x24.org>
Tue, 4 May 2021 05:14:19 +0000 (05:14 +0000)
committerEric Wong <e@80x24.org>
Tue, 4 May 2021 05:14:53 +0000 (05:14 +0000)
If lei_ls_mail_sync() is given a filter without any wildcards
and --globoff is unspecified, glob2re() will return undef,
resulting in the final regular expression being undefined.
Always use a fallback value when there's no RE.

Based-on-patch-by: Kyle Meyer <kyle@kyleam.com>
Link: https://public-inbox.org/meta/20210504044559.12941-5-kyle@kyleam.com/
lib/PublicInbox/LeiLsMailSync.pm

index 532ea9b542e803ac3c5d71268a86d6ddfe773fc6..505c0b3f55fcd95202c87ef3701f54785fd52730 100644 (file)
@@ -12,9 +12,8 @@ sub lei_ls_mail_sync {
        my $sto = $lei->_lei_store or return;
        my $lms = $sto->search->lms or return;
        my $opt = $lei->{opt};
-       my $re;
-       $re = defined($filter) ? qr/\Q$filter\E/ : qr/./ if $opt->{globoff};
-       $re //= $lei->glob2re($filter // '*');
+       my $re = $opt->{globoff} ? undef : $lei->glob2re($filter // '*');
+       $re //= qr/\Q$filter\E/;
        my @f = $lms->folders;
        @f = $opt->{'invert-match'} ? grep(!/$re/, @f) : grep(/$re/, @f);
        if ($opt->{'local'} && !$opt->{remote}) {