Skip to content

Commit

Permalink
Possible fix for the work-around for issue #485
Browse files Browse the repository at this point in the history
If the new problem reported in comment-293553102 is a
boundary issue (e.g. inptr == inend after skipping the
closing " char), this should solve the problem.
  • Loading branch information
jstedfast committed Apr 12, 2017
1 parent bc06cbf commit b8324a0
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions MailKit/Net/Imap/ImapStream.cs
Expand Up @@ -515,20 +515,20 @@ unsafe ImapToken ReadQuotedStringToken (byte* inbuf, CancellationToken cancellat
// skip over closing '"'
inptr++;

// Note: Some IMAP servers do not properly escape double-quotes inside
// of a qstring token and so, as an attempt at working around this
// problem, check that the closing '"' character is not immediately
// followed by any character that we would expect immediately following
// a qstring token.
//
// See https://github.com/jstedfast/MailKit/issues/485 for details.
if (inptr < inend && "]) \r\n".IndexOf ((char) *inptr) != -1)
break;

memory.WriteByte ((byte) '"');

if (inptr < inend)
if (inptr < inend) {
// Note: Some IMAP servers do not properly escape double-quotes inside
// of a qstring token and so, as an attempt at working around this
// problem, check that the closing '"' character is not immediately
// followed by any character that we would expect immediately following
// a qstring token.
//
// See https://github.com/jstedfast/MailKit/issues/485 for details.
if ("]) \r\n".IndexOf ((char) *inptr) != -1)
break;

memory.WriteByte ((byte) '"');
continue;
}
}

inputIndex = (int) (inptr - inbuf);
Expand Down

0 comments on commit b8324a0

Please sign in to comment.