user/dev discussion of public-inbox itself
 help / color / mirror / Atom feed
* [PATCH] imap: search support BODY key
@ 2020-08-06 21:43 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2020-08-06 21:43 UTC (permalink / raw)
  To: meta

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 | 3 +++
 t/imap_searchqp.t               | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/lib/PublicInbox/IMAPsearchqp.pm b/lib/PublicInbox/IMAPsearchqp.pm
index 4ea99ea5..5c82faa5 100644
--- a/lib/PublicInbox/IMAPsearchqp.pm
+++ b/lib/PublicInbox/IMAPsearchqp.pm
@@ -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 }
diff --git a/t/imap_searchqp.t b/t/imap_searchqp.t
index d62f314a..adf7b205 100644
--- a/t/imap_searchqp.t
+++ b/t/imap_searchqp.t
@@ -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")))',

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-08-06 21:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-06 21:43 [PATCH] imap: search support BODY key Eric Wong

user/dev discussion of public-inbox itself

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/meta
	git clone --mirror http://czquwvybam4bgbro.onion/meta
	git clone --mirror http://hjrcffqmbrq6wope.onion/meta
	git clone --mirror http://ou63pmih66umazou.onion/meta

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 meta meta/ https://public-inbox.org/meta \
		meta@public-inbox.org
	public-inbox-index meta

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.mail.public-inbox.meta
	nntp://ou63pmih66umazou.onion/inbox.comp.mail.public-inbox.meta
	nntp://czquwvybam4bgbro.onion/inbox.comp.mail.public-inbox.meta
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.mail.public-inbox.meta
	nntp://news.gmane.io/gmane.mail.public-inbox.general
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for the project(s) associated with this inbox:

	https://80x24.org/public-inbox.git

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git