]> Sergey Matveev's repositories - public-inbox.git/commitdiff
imap: STATUS and LIST are case-insensitive, too
authorEric Wong <e@yhbt.net>
Wed, 10 Jun 2020 07:04:45 +0000 (07:04 +0000)
committerEric Wong <e@yhbt.net>
Sat, 13 Jun 2020 07:55:45 +0000 (07:55 +0000)
Some clients insist on sending "INBOX" in all caps,
since it's special in RFC 3501.

lib/PublicInbox/IMAP.pm

index 5865822f0c3f12183d0390247e2ae590ee1c635b..8c6fa7b62c957a96d190d62d8717788253e7b0d5 100644 (file)
@@ -537,7 +537,7 @@ sub uid_fetch_m { # long_response
 
 sub cmd_status ($$$;@) {
        my ($self, $tag, $mailbox, @items) = @_;
-       my $ibx = $self->{imapd}->{mailboxes}->{$mailbox} or
+       my $ibx = $self->{imapd}->{mailboxes}->{lc $mailbox} or
                return "$tag NO Mailbox doesn't exist: $mailbox\r\n";
        return "$tag BAD no items\r\n" if !scalar(@items);
        ($items[0] !~ s/\A\(//s || $items[-1] !~ s/\)\z//s) and
@@ -571,7 +571,8 @@ sub cmd_list ($$$$) {
                # request for hierarchy delimiter
                $l = [ qq[* LIST (\\Noselect) "." ""\r\n] ];
        } elsif ($refname ne '' || $wildcard ne '*') {
-               $wildcard =~ s!([^a-z0-9_])!$patmap{$1} // "\Q$1"!eig;
+               $wildcard = lc $wildcard;
+               $wildcard =~ s!([^a-z0-9_])!$patmap{$1} // "\Q$1"!eg;
                $l = [ grep(/ \Q$refname\E$wildcard\r\n\z/s, @$l) ];
        }
        \(join('', @$l, "$tag OK List done\r\n"));