Skip to content

Commit

Permalink
Use token.Value.ToString() in case the token is a char token
Browse files Browse the repository at this point in the history
(causes InvalidCastException)
  • Loading branch information
jstedfast committed Mar 5, 2022
1 parent 16adde1 commit ab1e087
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion MailKit/Net/Imap/ImapCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,7 @@ public async Task<bool> StepAsync (bool doAsync)
if (token.Type != ImapTokenType.Eoln) {
// consume the rest of the line...
var line = (await Engine.ReadLineAsync (doAsync, CancellationToken).ConfigureAwait (false)).TrimEnd ();
ResponseText = ((string) token.Value) + line;
ResponseText = token.Value.ToString () + line;
break;
}
} else if (token.Type == ImapTokenType.OpenBracket) {
Expand Down
6 changes: 3 additions & 3 deletions MailKit/Net/Imap/ImapEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ public async Task ConnectAsync (ImapStream stream, bool doAsync, CancellationTok
}
} else if (token.Type != ImapTokenType.Eoln) {
text = (await ReadLineAsync (doAsync, cancellationToken).ConfigureAwait (false)).TrimEnd ();
text = ((string) token.Value) + text;
text = token.Value.ToString () + text;

if (bye)
throw new ImapProtocolException (text);
Expand Down Expand Up @@ -2045,7 +2045,7 @@ internal async Task<ImapUntaggedResult> ProcessUntaggedResponseAsync (bool doAsy
current.RespCodes.Add (code);
} else {
var text = (await ReadLineAsync (doAsync, cancellationToken).ConfigureAwait (false)).TrimEnd ();
current.ResponseText = ((string) token.Value) + text;
current.ResponseText = token.Value.ToString () + text;
}

current.Bye = true;
Expand Down Expand Up @@ -2097,7 +2097,7 @@ internal async Task<ImapUntaggedResult> ProcessUntaggedResponseAsync (bool doAsy
current.RespCodes.Add (code);
} else if (token.Type != ImapTokenType.Eoln) {
var text = (await ReadLineAsync (doAsync, cancellationToken).ConfigureAwait (false)).TrimEnd ();
current.ResponseText = ((string) token.Value) + text;
current.ResponseText = token.Value.ToString () + text;
}
} else {
if (uint.TryParse (atom, NumberStyles.None, CultureInfo.InvariantCulture, out uint number)) {
Expand Down

0 comments on commit ab1e087

Please sign in to comment.