about summary refs log tree commit homepage
path: root/lib/PublicInbox/IMAPsearchqp.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2020-08-29 20:32:19 +0000
committerEric Wong <e@yhbt.net>2020-08-30 07:31:46 +0000
commit374e1098fa03756e5626379ff6fe154785e16cfa (patch)
tree19066c6bb87f95840e4407e8862f8a83c0085354 /lib/PublicInbox/IMAPsearchqp.pm
parent0a3008a577406622a31b2ca3c099f7d61e766522 (diff)
downloadpublic-inbox-374e1098fa03756e5626379ff6fe154785e16cfa.tar.gz
Quiet down logs from -imapd when clients are blindly
sending some unsupported flag conditions (e.g. "DRAFT",
"DELETED") specified in RFC 3501.
Diffstat (limited to 'lib/PublicInbox/IMAPsearchqp.pm')
-rw-r--r--lib/PublicInbox/IMAPsearchqp.pm21
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/PublicInbox/IMAPsearchqp.pm b/lib/PublicInbox/IMAPsearchqp.pm
index 5c82faa5..190fefb9 100644
--- a/lib/PublicInbox/IMAPsearchqp.pm
+++ b/lib/PublicInbox/IMAPsearchqp.pm
@@ -162,11 +162,24 @@ sub msn_set {
         uid_set($self, $seq_set);
 }
 
+# things that should not match
+sub impossible {
+        my ($self) = @_;
+        push @{$self->{xap}}, 'bytes:..0';
+        my $sql = $self->{sql} or return 1;
+        $$sql .= ' AND num < 0';
+}
+
 my $prd = Parse::RecDescent->new(<<'EOG');
 <nocheck>
 { my $q = $PublicInbox::IMAPsearchqp::q; }
 search_key : CHARSET(?) search_key1(s) { $return = $q }
-search_key1 : "ALL" | "RECENT" | "UNSEEN" | "NEW"
+
+# n.b. we silently ignore most per-message flags right now;
+# they're here for now to not dump parser errors.
+search_key1 : "ALL" | "ANSWERED" | "RECENT" | "UNSEEN" | "SEEN" | "NEW"
+        | "UNANSWERED" | "UNDELETED" | "UNDRAFT" | "UNFLAGGED"
+        | DELETED | DRAFT | FLAGGED | OLD
         | OR_search_keys
         | NOT_search_key
         | LARGER_number
@@ -206,6 +219,12 @@ MSN_set : sequence_set { $q->msn_set($item{sequence_set}) }
 UID_set : "UID" sequence_set { $q->uid_set($item{sequence_set}) }
 LARGER_number : "LARGER" number { $q->xap_only("bytes:$item{number}..") }
 SMALLER_number : "SMALLER" number { $q->xap_only("bytes:..$item{number}") }
+
+DELETED : "DELETED" { $q->impossible }
+OLD : "OLD" { $q->impossible }
+FLAGGED : "FLAGGED" { $q->impossible }
+DRAFT : "DRAFT" { $q->impossible }
+
 # pass "NOT" through XXX is this right?
 OP_NOT : "NOT" { $q->xap_only('NOT') }
 NOT_search_key : OP_NOT search_key1