Skip to content

Commit

Permalink
Clear POP3 capabilities in QueryCapabilities instead of the CAPA call…
Browse files Browse the repository at this point in the history
…back handler

This way, if the server replies with -ERR in a subsequent CAPA query,
all capabilities are cleared. If the clearing happens in the callback
handler, then they are only updated if the server replies with a +OK
response.

Fixes issue #174
  • Loading branch information
jstedfast committed Apr 9, 2015
1 parent 74e8d94 commit 469996f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions MailKit/Net/Pop3/Pop3Engine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -445,13 +445,6 @@ public Pop3Command QueueCommand (CancellationToken cancellationToken, Pop3Comman

static void CapaHandler (Pop3Engine engine, Pop3Command pc, string text)
{
// clear all CAPA response capabilities (except the APOP capability)
engine.Capabilities &= Pop3Capabilities.Apop;
engine.AuthenticationMechanisms.Clear ();
engine.Implementation = null;
engine.ExpirePolicy = 0;
engine.LoginDelay = 0;

if (pc.Status != Pop3CommandStatus.Ok)
return;

Expand Down Expand Up @@ -542,6 +535,13 @@ public Pop3CommandStatus QueryCapabilities (CancellationToken cancellationToken)
if (stream == null)
throw new InvalidOperationException ();

// clear all CAPA response capabilities (except the APOP capability)
Capabilities &= Pop3Capabilities.Apop;
AuthenticationMechanisms.Clear ();
Implementation = null;
ExpirePolicy = 0;
LoginDelay = 0;

var pc = QueueCommand (cancellationToken, CapaHandler, "CAPA");

while (Iterate () < pc.Id) {
Expand Down

0 comments on commit 469996f

Please sign in to comment.