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-15 03:30:03 +0000
committerEric Wong <e@yhbt.net>2020-06-16 00:07:02 +0000
commit97cb0db690cc2065e7e3c33ea5f3636dc0b538c5 (patch)
tree94fd112bf18bc2a6b5039316c90e1148c3f7565a /lib/PublicInbox/IMAP.pm
parentbd55dffe2deafedeb9ac5f750dda46e3a2247018 (diff)
downloadpublic-inbox-97cb0db690cc2065e7e3c33ea5f3636dc0b538c5.tar.gz
"DONE" is a continuation and not a normal IMAP command, so
ensure it can't be called like a normal IMAP command which
has a tag.
Diffstat (limited to 'lib/PublicInbox/IMAP.pm')
-rw-r--r--lib/PublicInbox/IMAP.pm14
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/PublicInbox/IMAP.pm b/lib/PublicInbox/IMAP.pm
index bc890517..9ae7c60e 100644
--- a/lib/PublicInbox/IMAP.pm
+++ b/lib/PublicInbox/IMAP.pm
@@ -358,7 +358,7 @@ sub stop_idle ($$) {
         $ibx->unsubscribe_unlock($fd);
 }
 
-sub cmd_done ($$) {
+sub idle_done ($$) {
         my ($self, $tag) = @_; # $tag is "DONE" (case-insensitive)
         defined(my $idle_tag = delete $self->{-idle_tag}) or
                 return "$tag BAD not idle\r\n";
@@ -1310,12 +1310,12 @@ sub process_line ($$) {
                 $req .= "_".(shift @args);
         }
         my $res = eval {
-                if (my $cmd = $self->can('cmd_'.lc($req // ''))) {
-                        defined($self->{-idle_tag}) ?
-                                "$self->{-idle_tag} BAD expected DONE\r\n" :
-                                $cmd->($self, $tag, @args);
-                } elsif (uc($tag // '') eq 'DONE' && !defined($req)) {
-                        cmd_done($self, $tag);
+                if (defined(my $idle_tag = $self->{-idle_tag})) {
+                        (uc($tag // '') eq 'DONE' && !defined($req)) ?
+                                idle_done($self, $tag) :
+                                "$idle_tag BAD expected DONE\r\n";
+                } elsif (my $cmd = $self->can('cmd_'.lc($req // ''))) {
+                        $cmd->($self, $tag, @args);
                 } else { # this is weird
                         auth_challenge_ok($self) //
                                         ($tag // '*') .