unofficial mirror of meta@public-inbox.org
 help / color / Atom feed
* [PATCH] imap: clarify "DONE" usage with IDLE
@ 2020-06-15  3:30 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2020-06-15  3:30 UTC (permalink / raw)
  To: meta

"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.
---
 lib/PublicInbox/IMAP.pm | 14 +++++++-------
 1 file 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 // '*') .

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-15  3:30 [PATCH] imap: clarify "DONE" usage with IDLE Eric Wong

unofficial mirror of meta@public-inbox.org

Archives are clonable: git clone --mirror https://yhetil.org/meta

Example config snippet for mirrors

Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.mail.public-inbox.meta
	nntp://news.public-inbox.org/inbox.mail.public-inbox.meta
	nntp://news.gmane.io/gmane.mail.public-inbox.general


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git