fix 312952 handle IMAP input NIL patch by engel@physics.harvard.edu, r/sr=bienvenu

This commit is contained in:
bienvenu%nventure.com 2006-04-25 17:49:53 +00:00
Родитель 8b8ace82f9
Коммит 7be876c81c
2 изменённых файлов: 21 добавлений и 16 удалений

Просмотреть файл

@ -291,17 +291,21 @@ char *nsIMAPGenericParser::CreateAtom(PRBool isAstring)
return rv;
}
// CreateNilString creates either NIL (reutrns NULL) or a string
// CreateNilString return either NULL (for "NIL") or a string
// Call with fNextToken pointing to the thing which we think is the nilstring.
// This function leaves us off with fCurrentTokenPlaceHolder immediately after
// the end of the string, if it is a string, or at the NIL.
// the end of the string.
// Regardless of type, call AdvanceToNextToken() to get the token after it.
// RFC3501: nstring = string / nil
// nil = "NIL"
char *nsIMAPGenericParser::CreateNilString()
{
if (!PL_strncasecmp(fNextToken, "NIL", 3))
{
if (strlen(fNextToken) != 3)
fNextToken += 3;
// check if there is text after "NIL" in fNextToken,
// equivalent handling as in CreateQuoted
if (fNextToken[3])
AdvanceTokenizerStartingPoint((fNextToken - fLineOfTokens) + 3);
return NULL;
}
else

Просмотреть файл

@ -1391,12 +1391,18 @@ void nsImapServerResponseParser::envelope_data()
fNextToken++; // eat '('
for (int tableIndex = 0; tableIndex < (int)(sizeof(EnvelopeTable) / sizeof(EnvelopeTable[0])); tableIndex++)
{
PRBool headerNonNil = PR_TRUE;
if (ContinueParse() && (*fNextToken != ')'))
if (!ContinueParse())
break;
else if (*fNextToken == ')')
{
SetSyntaxError(PR_TRUE); // envelope too short
break;
}
else
{
nsCAutoString headerLine(EnvelopeTable[tableIndex].name);
headerLine += ": ";
PRBool headerNonNil = PR_TRUE;
if (EnvelopeTable[tableIndex].type == envelopeString)
{
nsXPIDLCString strValue;
@ -1419,13 +1425,11 @@ void nsImapServerResponseParser::envelope_data()
if (headerNonNil)
fServerConnection.HandleMessageDownLoadLine(headerLine.get(), PR_FALSE);
}
else
break;
// only fetch the next token if we aren't eating a parenthes
if (ContinueParse() && (*fNextToken != ')') || tableIndex < (int)(sizeof(EnvelopeTable) / sizeof(EnvelopeTable[0])) - 1 )
if (ContinueParse())
AdvanceToNextToken();
}
// Now we should be at the end of the envelope and have *fToken == ')'.
// Skip this last parenthesis.
AdvanceToNextToken();
}
@ -1521,10 +1525,7 @@ void nsImapServerResponseParser::parse_address(nsCAutoString &addressLine)
{
AdvanceToNextToken();
char *hostName = CreateNilString();
// our tokenizer doesn't handle "NIL)" quite like we
// expect, so we need to check specially for this.
if (hostName || *fNextToken != ')')
AdvanceToNextToken(); // skip hostName
AdvanceToNextToken();
addressLine += mailboxName;
if (hostName)
{