From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS3215 2.0.0.0/16 X-Spam-Status: No, score=-3.2 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from out0.migadu.com (out0.migadu.com [IPv6:2001:41d0:2:267::]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 271821F9F4 for ; Tue, 4 May 2021 04:46:18 +0000 (UTC) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kyleam.com; s=key1; t=1620103575; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=h8Sf6c6zdeayZrBEsk7QQlsRB2SVSV/FgoMGkstNee4=; b=fmvZM6zSzuqc+VIiogG5yvUuKaSpWRiTj3tMCNrJb1lThohV1CSYRCoWO3NYJHOY8f+JRN 9JMxyzns+cGiNv9nev/Hp+tmuE51TmIgD+e7lkARYy1izYesZc5ojyXTyt4jkgysS1GKr8 EeeysIHU6Xsg0nw8CvaFeUsOAfXa+IHkjMeeWyPZM7DMiyH4T2Ly5qgkmBL1G4cSAa5FNm /SXm/fQTZJzpDOhpXK0oHWcR2AnDQfCheUDymPdF8vVIbLroH4sOZYin5DNBNutOFCAnfY iOMTyOXB8lrRACm4Me88mA3KNio4TGem4YI1wsM/YMM3FHPx2pfJ1QWWra4KQQ== From: Kyle Meyer To: meta@public-inbox.org Subject: [PATCH 4/5] lei ls-mail-sync: fix handling of non-wildcard filters Date: Tue, 4 May 2021 00:45:58 -0400 Message-Id: <20210504044559.12941-5-kyle@kyleam.com> In-Reply-To: <20210504044559.12941-1-kyle@kyleam.com> References: <20210504044559.12941-1-kyle@kyleam.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: kyle@kyleam.com List-Id: 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. Add a fallback value. --- I'm not sure if this is the cleanest approach; repeating qr/\Q$filter\E/ seems ugly. I considered something closer to what lei_ls_external() does, but decided against it because it leads to --globoff with no filter showing no output, which I think is surprising (even if passing --globoff with no filter doesn't make any sense). This probably deserves a test, but I'm out of time for tonight. If the change looks okay, I'm happy to look into adding a test tomorrow. lib/PublicInbox/LeiLsMailSync.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/PublicInbox/LeiLsMailSync.pm b/lib/PublicInbox/LeiLsMailSync.pm index 532ea9b5..06e25a63 100644 --- a/lib/PublicInbox/LeiLsMailSync.pm +++ b/lib/PublicInbox/LeiLsMailSync.pm @@ -14,7 +14,7 @@ sub lei_ls_mail_sync { my $opt = $lei->{opt}; my $re; $re = defined($filter) ? qr/\Q$filter\E/ : qr/./ if $opt->{globoff}; - $re //= $lei->glob2re($filter // '*'); + $re //= $lei->glob2re($filter // '*') // qr/\Q$filter\E/;; my @f = $lms->folders; @f = $opt->{'invert-match'} ? grep(!/$re/, @f) : grep(/$re/, @f); if ($opt->{'local'} && !$opt->{remote}) { -- 2.31.1