]> Sergey Matveev's repositories - public-inbox.git/commit
imap: *SEARCH: use Parse::RecDescent
authorEric Wong <e@yhbt.net>
Tue, 16 Jun 2020 05:05:40 +0000 (05:05 +0000)
committerEric Wong <e@yhbt.net>
Tue, 16 Jun 2020 21:41:56 +0000 (21:41 +0000)
commit07caa8528db2ac22d81a0763e1cefd59acd827f1
treeaae828ad005dc59ad66d9e7d620d81bf669ba796
parent95efed60fe2d20ee4382c485e7faf58b3fee25af
imap: *SEARCH: use Parse::RecDescent

For properly parsing IMAP search requests, it's easier to use a
recursive descent parser generator to deal with subqueries and
the "OR" statement.

Parse::RecDescent was chosen since it's mature, well-known,
widely available and already used by our optional dependencies:
Inline::C and Mail::IMAPClient.  While it's possible to build
Xapian queries without using the Xapian string query parser;
this iteration of the IMAP parser still builds a string which is
passed to Xapian's query parser for ease-of-diagnostics.

Since this is a recursive descent parser dealing with untrusted
inputs, subqueries have a nesting limit of 10.  I expect that is
more than adequate for real-world use.
MANIFEST
lib/PublicInbox/IMAP.pm
lib/PublicInbox/IMAPsearchqp.pm [new file with mode: 0644]
t/imap.t
t/imap_searchqp.t [new file with mode: 0644]
t/imapd-tls.t
t/imapd.t
xt/mem-imapd-tls.t