Skip to content

Commit

Permalink
Fixed the IMAP parser to properly accept qstrings (and literals) for …
Browse files Browse the repository at this point in the history
…the header field names

Fixes issue #115
  • Loading branch information
jstedfast committed Nov 21, 2014
1 parent 58659dc commit adc50f9
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions MailKit/Net/Imap/ImapFolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2185,8 +2185,17 @@ static void FetchSummaryItems (ImapEngine engine, ImapCommand ic, int index)
if (token.Type == ImapTokenType.CloseParen)
break;

if (token.Type != ImapTokenType.Atom)
// the header field names will generally be atoms or qstrings but may also be literals
switch (token.Type) {
case ImapTokenType.Literal:
engine.ReadLiteral (ic.CancellationToken);
break;
case ImapTokenType.QString:
case ImapTokenType.Atom:
break;
default:
throw ImapEngine.UnexpectedToken (token, false);
}
} while (true);
} else if (token.Type != ImapTokenType.Atom) {
throw ImapEngine.UnexpectedToken (token, false);
Expand Down Expand Up @@ -3387,8 +3396,17 @@ static void FetchMessageBody (ImapEngine engine, ImapCommand ic, int index)
if (token.Type == ImapTokenType.CloseParen)
break;

if (token.Type != ImapTokenType.Atom)
// the header field names will generally be atoms or qstrings but may also be literals
switch (token.Type) {
case ImapTokenType.Literal:
engine.ReadLiteral (ic.CancellationToken);
break;
case ImapTokenType.QString:
case ImapTokenType.Atom:
break;
default:
throw ImapEngine.UnexpectedToken (token, false);
}
} while (true);
} else if (token.Type != ImapTokenType.Atom) {
throw ImapEngine.UnexpectedToken (token, false);
Expand Down

0 comments on commit adc50f9

Please sign in to comment.