about summary refs log tree commit homepage
path: root/lib/PublicInbox/IMAP.pm
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-06-16 07:04:26 +0000
committerEric Wong <e@yhbt.net>2020-06-16 21:41:58 +0000
commitbdee1f6bfaa0017877e5d5284c2d5e41f67e847a (patch)
tree14233ad3a517acb774418b80afa36a861561da37 /lib/PublicInbox/IMAP.pm
parent07caa8528db2ac22d81a0763e1cefd59acd827f1 (diff)
downloadpublic-inbox-bdee1f6bfaa0017877e5d5284c2d5e41f67e847a.tar.gz
We no longer pass an arrayref to search_common() or
parse_query(), so handle the CHARSET directive in
the Parse::RecDescent-generated parser directly.
Diffstat (limited to 'lib/PublicInbox/IMAP.pm')
-rw-r--r--lib/PublicInbox/IMAP.pm23
1 files changed, 9 insertions, 14 deletions
diff --git a/lib/PublicInbox/IMAP.pm b/lib/PublicInbox/IMAP.pm
index dd983dfd..64b57a3e 100644
--- a/lib/PublicInbox/IMAP.pm
+++ b/lib/PublicInbox/IMAP.pm
@@ -1154,13 +1154,8 @@ sub xap_append ($$$$) {
 }
 
 sub parse_query ($$) {
-        my ($self, $rest) = @_;
-        if (uc($rest->[0]) eq 'CHARSET') {
-                shift @$rest;
-                defined(my $c = shift @$rest) or return 'BAD missing charset';
-                $c =~ /\A(?:UTF-8|US-ASCII)\z/ or return 'NO [BADCHARSET]';
-        }
-        my $q = PublicInbox::IMAPsearchqp::parse($self, join(' ', @$rest));
+        my ($self, $query) = @_;
+        my $q = PublicInbox::IMAPsearchqp::parse($self, $query);
         if (ref($q)) {
                 my $max = $self->{ibx}->over->max;
                 my $beg = 1;
@@ -1202,9 +1197,9 @@ sub search_xap_range { # long_response
 }
 
 sub search_common {
-        my ($self, $tag, $rest, $want_msn) = @_;
+        my ($self, $tag, $query, $want_msn) = @_;
         my $ibx = $self->{ibx} or return "$tag BAD No mailbox selected\r\n";
-        my $q = parse_query($self, $rest);
+        my $q = parse_query($self, $query);
         return "$tag $q\r\n" if !ref($q);
         my ($sql, $range_info) = delete @$q{qw(sql range_info)};
         if (!scalar(keys %$q)) { # overview.sqlite3
@@ -1222,14 +1217,14 @@ sub search_common {
         }
 }
 
-sub cmd_uid_search ($$$;) {
-        my ($self, $tag) = splice(@_, 0, 2);
-        search_common($self, $tag, \@_);
+sub cmd_uid_search ($$$) {
+        my ($self, $tag, $query) = @_;
+        search_common($self, $tag, $query);
 }
 
 sub cmd_search ($$$;) {
-        my ($self, $tag) = splice(@_, 0, 2);
-        search_common($self, $tag, \@_, 1);
+        my ($self, $tag, $query) = @_;
+        search_common($self, $tag, $query, 1);
 }
 
 sub args_ok ($$) { # duplicated from PublicInbox::NNTP