]> Sergey Matveev's repositories - public-inbox.git/commitdiff
imap: search support BODY key
authorEric Wong <e@80x24.org>
Thu, 6 Aug 2020 21:43:46 +0000 (21:43 +0000)
committerEric Wong <e@yhbt.net>
Fri, 7 Aug 2020 23:44:40 +0000 (23:44 +0000)
This is specified in RFC 3501 but was accidentally omitted :x
I probably got it confused with TEXT, so add a comment about
TEXT being "everything" in the message.

lib/PublicInbox/IMAPsearchqp.pm
t/imap_searchqp.t

index 4ea99ea500bc61988b45f15c4d12e896489fb387..5c82faa5cfcf201282320e06643e03bfcc766b61 100644 (file)
@@ -18,6 +18,7 @@ my %MM = map {; $MoY[$_-1] => sprintf('%02u', $_) } (1..12);
 my %IH2X = (
        SUBJECT => 's:',
        BODY => 'b:',
+       # TEXT => undef, # => everything
        FROM => 'f:',
        TO => 't:',
        CC => 'c:',
@@ -182,6 +183,7 @@ search_key1 : "ALL" | "RECENT" | "UNSEEN" | "NEW"
        | CC_string
        | BCC_string
        | SUBJECT_string
+       | BODY_string
        | TEXT_string
        | UID_set
        | MSN_set
@@ -239,6 +241,7 @@ TO_string : "TO" string { $q->ih2x('TO', $item{string}) }
 CC_string : "CC" string { $q->ih2x('CC', $item{string}) }
 BCC_string : "BCC" string { $q->ih2x('BCC', $item{string}) }
 SUBJECT_string : "SUBJECT" string { $q->ih2x('SUBJECT', $item{string}) }
+BODY_string : "BODY" string { $q->ih2x('BODY', $item{string}) }
 TEXT_string : "TEXT" string { $q->ih2x(undef, $item{string}) }
 op_subq_enter : '(' { $q->subq_enter }
 sub_query : op_subq_enter search_key1(s) ')' { $q->subq_leave }
index d62f314a2a20db6a6de134b432881fa3ea313849..adf7b20508906e98b5752f88b36dd6e565575cec 100644 (file)
@@ -14,6 +14,9 @@ my $imap = bless {}, 'PublicInbox::IMAP';
 my $q;
 my $parse = sub { PublicInbox::IMAPsearchqp::parse($imap, $_[0]) };
 
+$q = $parse->(qq{BODY oops});
+is($q->{xap}, 'b:"oops"', 'BODY key supported');
+
 $q = $parse->(qq{OR HEADER TO Brian (OR FROM Ryan (OR TO Joe CC Scott))});
 is($q->{sql}, undef, 'not using SQLite for complex query');
 is($q->{xap}, '(t:"brian" OR (f:"ryan" OR (t:"joe" OR c:"scott")))',