]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei mark: relax label requirements
authorEric Wong <e@80x24.org>
Sat, 27 Mar 2021 23:22:38 +0000 (23:22 +0000)
committerEric Wong <e@80x24.org>
Sun, 28 Mar 2021 02:43:50 +0000 (02:43 +0000)
It seems safe to use ALLCAPS labels like "INBOX" with Xapian.
We'll also allow single-character labels.

lib/PublicInbox/LeiMark.pm
t/lei-mark.t

index 6d236411b4639d03b100ff5a46c42f9da3d9f06c..34846b842a5aff01164dd0662b8a210dd98310e4 100644 (file)
@@ -23,7 +23,7 @@ my %ERR = (
                my ($label) = @_;
                length($label) >= $L_MAX and
                        return "`$label' too long (must be <= $L_MAX)";
-               $label =~ m{\A[a-z0-9_][a-z0-9_\-\./\@,]*[a-z0-9]\z} ?
+               $label =~ m{\A[a-z0-9_](?:[a-z0-9_\-\./\@,]*[a-z0-9])?\z}i ?
                        undef : "`$label' is invalid";
        },
        kw => sub {
index 23f5002ed9495644f052b02aff6841ccb1e51c67..7855839e31a2c5e2730d8b3da3cfe765be3c3b02 100644 (file)
@@ -78,6 +78,12 @@ test_lei(sub {
        lei_ok(qw(ls-label));
        is($lei_out, "nope\nqp\nurgent\n", 'ls-label shows qp');
 
+       lei_ok qw(mark -F eml t/utf8.eml +L:INBOX +L:x); diag $lei_err;
+       lei_ok qw(q m:testmessage@example.com);
+       $check_kw->([qw(answered seen)], L => [qw(INBOX nope urgent x)]);
+       lei_ok(qw(ls-label));
+       is($lei_out, "INBOX\nnope\nqp\nurgent\nx\n", 'ls-label shows qp');
+
        if (0) { # TODO label+kw search w/ externals
                lei_ok(qw(q L:qp), "mid:$mid", '--only', "$ro_home/t2");
        }