]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/IMAP.pm
www_stream: add trailing slash for help and color links
[public-inbox.git] / lib / PublicInbox / IMAP.pm
index f123eb01a519ea6114b65834d5abbfafddc39631..af8ce72be48a61df36bec17183fa061a0f2bffae 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2020 all contributors <meta@public-inbox.org>
+# Copyright (C) 2020-2021 all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 #
 # Each instance of this represents an IMAP client connected to
@@ -499,7 +499,7 @@ sub body_disposition ($) {
        my $cd = $eml->header_raw('Content-Disposition') or return 'NIL';
        $cd = parse_content_disposition($cd);
        my $buf = '('._esc($cd->{type});
-       $buf .= ' ' . _esc_hash(delete $cd->{attributes});
+       $buf .= ' ' . _esc_hash($cd->{attributes});
        $buf .= ')';
 }
 
@@ -511,7 +511,7 @@ sub body_leaf ($$;$) {
        my $ct = $eml->ct;
        $buf .= '('._esc($ct->{type}).' ';
        $buf .= _esc($ct->{subtype});
-       $buf .= ' ' . _esc_hash(delete $ct->{attributes});
+       $buf .= ' ' . _esc_hash($ct->{attributes});
        $buf .= ' ' . _esc($eml->header_raw('Content-ID'));
        $buf .= ' ' . _esc($eml->header_raw('Content-Description'));
        my $cte = $eml->header_raw('Content-Transfer-Encoding') // '7bit';
@@ -540,7 +540,7 @@ sub body_parent ($$$) {
                $buf .= @$hold ? join('', @$hold) : 'NIL';
                $buf .= ' '._esc($ct->{subtype});
                if ($structure) {
-                       $buf .= ' '._esc_hash(delete $ct->{attributes});
+                       $buf .= ' '._esc_hash($ct->{attributes});
                        $buf .= ' '.body_disposition($eml);
                        $buf .= ' '._esc($eml->header_raw('Content-Language'));
                        $buf .= ' '._esc($eml->header_raw('Content-Location'));
@@ -1110,7 +1110,7 @@ sub search_uid_range { # long_response
        1; # more
 }
 
-sub parse_query ($$) {
+sub parse_imap_query ($$) {
        my ($self, $query) = @_;
        my $q = PublicInbox::IMAPsearchqp::parse($self, $query);
        if (ref($q)) {
@@ -1125,7 +1125,7 @@ sub parse_query ($$) {
 sub search_common {
        my ($self, $tag, $query, $want_msn) = @_;
        my $ibx = $self->{ibx} or return "$tag BAD No mailbox selected\r\n";
-       my $q = parse_query($self, $query);
+       my $q = parse_imap_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
@@ -1136,13 +1136,13 @@ sub search_common {
                my $srch = $self->{ibx}->isrch or
                        return "$tag BAD search not available for mailbox\r\n";
                my $opt = {
-                       mset => 2,
+                       relevance => -1,
                        limit => UID_SLICE,
                        uid_range => $range_info
                };
                my $mset = $srch->mset($q, $opt);
                my $uids = $srch->mset_to_artnums($mset, $opt);
-               msn_convert($self, $uids) if $want_msn;
+               msn_convert($self, $uids) if scalar(@$uids) && $want_msn;
                "* SEARCH @$uids\r\n$tag OK Search done\r\n";
        } else {
                "$tag BAD Error\r\n";