зеркало из https://github.com/mozilla/pjs.git
fix multiple connection protection code by making sure host name is set correctly when processing selected state url, fixes a regression by backing out one line of change r/sr/a=sspizer 215776
This commit is contained in:
Родитель
49646fc97a
Коммит
93ce81336f
|
@ -1945,6 +1945,8 @@ void nsImapProtocol::ProcessSelectedStateURL()
|
||||||
imapMessageFlagsType msgFlags = 0;
|
imapMessageFlagsType msgFlags = 0;
|
||||||
nsCString urlHost;
|
nsCString urlHost;
|
||||||
|
|
||||||
|
(void) GetImapHostName(); // force m_hostName to get set.
|
||||||
|
|
||||||
// this can't fail, can it?
|
// this can't fail, can it?
|
||||||
nsresult res;
|
nsresult res;
|
||||||
res = m_runningUrl->GetImapAction(&m_imapAction);
|
res = m_runningUrl->GetImapAction(&m_imapAction);
|
||||||
|
@ -2841,186 +2843,186 @@ nsImapProtocol::FetchMessage(const char * messageIds,
|
||||||
PRUint32 startByte, PRUint32 endByte,
|
PRUint32 startByte, PRUint32 endByte,
|
||||||
char *part)
|
char *part)
|
||||||
{
|
{
|
||||||
IncrementCommandTagNumber();
|
IncrementCommandTagNumber();
|
||||||
|
|
||||||
nsCString commandString;
|
nsCString commandString;
|
||||||
if (idIsUid)
|
if (idIsUid)
|
||||||
commandString = "%s UID fetch";
|
commandString = "%s UID fetch";
|
||||||
|
else
|
||||||
|
commandString = "%s fetch";
|
||||||
|
|
||||||
|
switch (whatToFetch) {
|
||||||
|
case kEveryThingRFC822:
|
||||||
|
m_flagChangeCount++;
|
||||||
|
GetServerStateParser().SetFetchingEverythingRFC822(PR_TRUE);
|
||||||
|
if (m_trackingTime)
|
||||||
|
AdjustChunkSize(); // we started another segment
|
||||||
|
m_startTime = PR_Now(); // save start of download time
|
||||||
|
m_trackingTime = PR_TRUE;
|
||||||
|
if (GetServerStateParser().ServerHasIMAP4Rev1Capability())
|
||||||
|
{
|
||||||
|
if (GetServerStateParser().GetCapabilityFlag() & kHasXSenderCapability)
|
||||||
|
commandString.Append(" %s (XSENDER UID RFC822.SIZE BODY[]");
|
||||||
|
else
|
||||||
|
commandString.Append(" %s (UID RFC822.SIZE BODY[]");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
commandString = "%s fetch";
|
{
|
||||||
|
if (GetServerStateParser().GetCapabilityFlag() & kHasXSenderCapability)
|
||||||
|
commandString.Append(" %s (XSENDER UID RFC822.SIZE RFC822");
|
||||||
|
else
|
||||||
|
commandString.Append(" %s (UID RFC822.SIZE RFC822");
|
||||||
|
}
|
||||||
|
if (endByte > 0)
|
||||||
|
{
|
||||||
|
// if we are retrieving chunks
|
||||||
|
char *byterangeString = PR_smprintf("<%ld.%ld>",startByte,endByte);
|
||||||
|
if (byterangeString)
|
||||||
|
{
|
||||||
|
commandString.Append(byterangeString);
|
||||||
|
PR_Free(byterangeString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
commandString.Append(")");
|
||||||
|
|
||||||
switch (whatToFetch) {
|
break;
|
||||||
case kEveryThingRFC822:
|
|
||||||
m_flagChangeCount++;
|
case kEveryThingRFC822Peek:
|
||||||
GetServerStateParser().SetFetchingEverythingRFC822(PR_TRUE);
|
{
|
||||||
if (m_trackingTime)
|
const char *formatString = "";
|
||||||
AdjustChunkSize(); // we started another segment
|
PRUint32 server_capabilityFlags = GetServerStateParser().GetCapabilityFlag();
|
||||||
m_startTime = PR_Now(); // save start of download time
|
|
||||||
m_trackingTime = PR_TRUE;
|
GetServerStateParser().SetFetchingEverythingRFC822(PR_TRUE);
|
||||||
if (GetServerStateParser().ServerHasIMAP4Rev1Capability())
|
if (server_capabilityFlags & kIMAP4rev1Capability)
|
||||||
{
|
|
||||||
if (GetServerStateParser().GetCapabilityFlag() & kHasXSenderCapability)
|
|
||||||
commandString.Append(" %s (XSENDER UID RFC822.SIZE BODY[]");
|
|
||||||
else
|
|
||||||
commandString.Append(" %s (UID RFC822.SIZE BODY[]");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (GetServerStateParser().GetCapabilityFlag() & kHasXSenderCapability)
|
|
||||||
commandString.Append(" %s (XSENDER UID RFC822.SIZE RFC822");
|
|
||||||
else
|
|
||||||
commandString.Append(" %s (UID RFC822.SIZE RFC822");
|
|
||||||
}
|
|
||||||
if (endByte > 0)
|
|
||||||
{
|
|
||||||
// if we are retrieving chunks
|
|
||||||
char *byterangeString = PR_smprintf("<%ld.%ld>",startByte,endByte);
|
|
||||||
if (byterangeString)
|
|
||||||
{
|
|
||||||
commandString.Append(byterangeString);
|
|
||||||
PR_Free(byterangeString);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
commandString.Append(")");
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case kEveryThingRFC822Peek:
|
|
||||||
{
|
|
||||||
const char *formatString = "";
|
|
||||||
PRUint32 server_capabilityFlags = GetServerStateParser().GetCapabilityFlag();
|
|
||||||
|
|
||||||
GetServerStateParser().SetFetchingEverythingRFC822(PR_TRUE);
|
|
||||||
if (server_capabilityFlags & kIMAP4rev1Capability)
|
|
||||||
{
|
|
||||||
// use body[].peek since rfc822.peek is not in IMAP4rev1
|
|
||||||
if (server_capabilityFlags & kHasXSenderCapability)
|
|
||||||
formatString = " %s (XSENDER UID RFC822.SIZE BODY.PEEK[])";
|
|
||||||
else
|
|
||||||
formatString = " %s (UID RFC822.SIZE BODY.PEEK[])";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (server_capabilityFlags & kHasXSenderCapability)
|
|
||||||
formatString = " %s (XSENDER UID RFC822.SIZE RFC822.peek)";
|
|
||||||
else
|
|
||||||
formatString = " %s (UID RFC822.SIZE RFC822.peek)";
|
|
||||||
}
|
|
||||||
|
|
||||||
commandString.Append(formatString);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case kHeadersRFC822andUid:
|
|
||||||
if (GetServerStateParser().ServerHasIMAP4Rev1Capability())
|
|
||||||
{
|
{
|
||||||
PRUint32 server_capabilityFlags = GetServerStateParser().GetCapabilityFlag();
|
// use body[].peek since rfc822.peek is not in IMAP4rev1
|
||||||
PRBool aolImapServer = ((server_capabilityFlags & kAOLImapCapability) != 0);
|
if (server_capabilityFlags & kHasXSenderCapability)
|
||||||
PRBool downloadAllHeaders = PR_FALSE;
|
formatString = " %s (XSENDER UID RFC822.SIZE BODY.PEEK[])";
|
||||||
// checks if we're filtering on "any header" or running a spam filter requiring all headers
|
else
|
||||||
GetShouldDownloadAllHeaders(&downloadAllHeaders);
|
formatString = " %s (UID RFC822.SIZE BODY.PEEK[])";
|
||||||
|
}
|
||||||
if (!downloadAllHeaders) // if it's ok -- no filters on any header, etc.
|
else
|
||||||
|
{
|
||||||
|
if (server_capabilityFlags & kHasXSenderCapability)
|
||||||
|
formatString = " %s (XSENDER UID RFC822.SIZE RFC822.peek)";
|
||||||
|
else
|
||||||
|
formatString = " %s (UID RFC822.SIZE RFC822.peek)";
|
||||||
|
}
|
||||||
|
|
||||||
|
commandString.Append(formatString);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case kHeadersRFC822andUid:
|
||||||
|
if (GetServerStateParser().ServerHasIMAP4Rev1Capability())
|
||||||
|
{
|
||||||
|
PRUint32 server_capabilityFlags = GetServerStateParser().GetCapabilityFlag();
|
||||||
|
PRBool aolImapServer = ((server_capabilityFlags & kAOLImapCapability) != 0);
|
||||||
|
PRBool downloadAllHeaders = PR_FALSE;
|
||||||
|
// checks if we're filtering on "any header" or running a spam filter requiring all headers
|
||||||
|
GetShouldDownloadAllHeaders(&downloadAllHeaders);
|
||||||
|
|
||||||
|
if (!downloadAllHeaders) // if it's ok -- no filters on any header, etc.
|
||||||
|
{
|
||||||
|
char *headersToDL = nsnull;
|
||||||
|
char *what = nsnull;
|
||||||
|
const char *dbHeaders = (gUseEnvelopeCmd) ? IMAP_DB_HEADERS : IMAP_ENV_AND_DB_HEADERS;
|
||||||
|
nsXPIDLCString arbitraryHeaders;
|
||||||
|
GetArbitraryHeadersToDownload(getter_Copies(arbitraryHeaders));
|
||||||
|
if (arbitraryHeaders.IsEmpty())
|
||||||
|
headersToDL = nsCRT::strdup(dbHeaders);
|
||||||
|
else
|
||||||
|
headersToDL = PR_smprintf("%s %s",dbHeaders, arbitraryHeaders.get());
|
||||||
|
|
||||||
|
if (aolImapServer)
|
||||||
|
what = strdup(" XAOL-ENVELOPE INTERNALDATE)");
|
||||||
|
else if (gUseEnvelopeCmd)
|
||||||
|
what = PR_smprintf(" ENVELOPE BODY.PEEK[HEADER.FIELDS (%s)])", headersToDL);
|
||||||
|
else
|
||||||
|
what = PR_smprintf(" BODY.PEEK[HEADER.FIELDS (%s)])",headersToDL);
|
||||||
|
nsCRT::free(headersToDL);
|
||||||
|
if (what)
|
||||||
{
|
{
|
||||||
char *headersToDL = nsnull;
|
commandString.Append(" %s (UID ");
|
||||||
char *what = nsnull;
|
|
||||||
const char *dbHeaders = (gUseEnvelopeCmd) ? IMAP_DB_HEADERS : IMAP_ENV_AND_DB_HEADERS;
|
|
||||||
nsXPIDLCString arbitraryHeaders;
|
|
||||||
GetArbitraryHeadersToDownload(getter_Copies(arbitraryHeaders));
|
|
||||||
if (arbitraryHeaders.IsEmpty())
|
|
||||||
headersToDL = nsCRT::strdup(dbHeaders);
|
|
||||||
else
|
|
||||||
headersToDL = PR_smprintf("%s %s",dbHeaders, arbitraryHeaders.get());
|
|
||||||
|
|
||||||
if (aolImapServer)
|
if (aolImapServer)
|
||||||
what = strdup(" XAOL-ENVELOPE INTERNALDATE)");
|
commandString.Append(" XAOL.SIZE") ;
|
||||||
else if (gUseEnvelopeCmd)
|
|
||||||
what = PR_smprintf(" ENVELOPE BODY.PEEK[HEADER.FIELDS (%s)])", headersToDL);
|
|
||||||
else
|
else
|
||||||
what = PR_smprintf(" BODY.PEEK[HEADER.FIELDS (%s)])",headersToDL);
|
commandString.Append("RFC822.SIZE");
|
||||||
nsCRT::free(headersToDL);
|
commandString.Append(" FLAGS");
|
||||||
if (what)
|
commandString.Append(what);
|
||||||
{
|
PR_Free(what);
|
||||||
commandString.Append(" %s (UID ");
|
|
||||||
if (aolImapServer)
|
|
||||||
commandString.Append(" XAOL.SIZE") ;
|
|
||||||
else
|
|
||||||
commandString.Append("RFC822.SIZE");
|
|
||||||
commandString.Append(" FLAGS");
|
|
||||||
commandString.Append(what);
|
|
||||||
PR_Free(what);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
commandString.Append(" %s (UID RFC822.SIZE BODY.PEEK[HEADER] FLAGS)");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
commandString.Append(" %s (UID RFC822.SIZE BODY.PEEK[HEADER] FLAGS)");
|
commandString.Append(" %s (UID RFC822.SIZE BODY.PEEK[HEADER] FLAGS)");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
commandString.Append(" %s (UID RFC822.SIZE RFC822.HEADER FLAGS)");
|
commandString.Append(" %s (UID RFC822.SIZE BODY.PEEK[HEADER] FLAGS)");
|
||||||
break;
|
}
|
||||||
case kUid:
|
else
|
||||||
commandString.Append(" %s (UID)");
|
commandString.Append(" %s (UID RFC822.SIZE RFC822.HEADER FLAGS)");
|
||||||
break;
|
break;
|
||||||
case kFlags:
|
case kUid:
|
||||||
GetServerStateParser().SetFetchingFlags(PR_TRUE);
|
commandString.Append(" %s (UID)");
|
||||||
commandString.Append(" %s (FLAGS)");
|
break;
|
||||||
break;
|
case kFlags:
|
||||||
case kRFC822Size:
|
GetServerStateParser().SetFetchingFlags(PR_TRUE);
|
||||||
commandString.Append(" %s (RFC822.SIZE)");
|
commandString.Append(" %s (FLAGS)");
|
||||||
break;
|
break;
|
||||||
case kRFC822HeadersOnly:
|
case kRFC822Size:
|
||||||
if (GetServerStateParser().ServerHasIMAP4Rev1Capability())
|
commandString.Append(" %s (RFC822.SIZE)");
|
||||||
|
break;
|
||||||
|
case kRFC822HeadersOnly:
|
||||||
|
if (GetServerStateParser().ServerHasIMAP4Rev1Capability())
|
||||||
|
{
|
||||||
|
if (part)
|
||||||
{
|
{
|
||||||
if (part)
|
commandString.Append(" %s (BODY[");
|
||||||
|
char *what = PR_smprintf("%s.HEADER])", part);
|
||||||
|
if (what)
|
||||||
{
|
{
|
||||||
commandString.Append(" %s (BODY[");
|
commandString.Append(what);
|
||||||
char *what = PR_smprintf("%s.HEADER])", part);
|
PR_Free(what);
|
||||||
if (what)
|
|
||||||
{
|
|
||||||
commandString.Append(what);
|
|
||||||
PR_Free(what);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
HandleMemoryFailure();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
HandleMemoryFailure();
|
||||||
// headers for the top-level message
|
|
||||||
commandString.Append(" %s (BODY[HEADER])");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
commandString.Append(" %s (RFC822.HEADER)");
|
|
||||||
break;
|
|
||||||
case kMIMEPart:
|
|
||||||
commandString.Append(" %s (BODY[%s]");
|
|
||||||
if (endByte > 0)
|
|
||||||
{
|
{
|
||||||
// if we are retrieving chunks
|
// headers for the top-level message
|
||||||
char *byterangeString = PR_smprintf("<%ld.%ld>",startByte,endByte);
|
commandString.Append(" %s (BODY[HEADER])");
|
||||||
if (byterangeString)
|
|
||||||
{
|
|
||||||
commandString.Append(byterangeString);
|
|
||||||
PR_Free(byterangeString);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
commandString.Append(")");
|
}
|
||||||
break;
|
else
|
||||||
case kMIMEHeader:
|
commandString.Append(" %s (RFC822.HEADER)");
|
||||||
commandString.Append(" %s (BODY[%s.MIME])");
|
break;
|
||||||
break;
|
case kMIMEPart:
|
||||||
|
commandString.Append(" %s (BODY[%s]");
|
||||||
|
if (endByte > 0)
|
||||||
|
{
|
||||||
|
// if we are retrieving chunks
|
||||||
|
char *byterangeString = PR_smprintf("<%ld.%ld>",startByte,endByte);
|
||||||
|
if (byterangeString)
|
||||||
|
{
|
||||||
|
commandString.Append(byterangeString);
|
||||||
|
PR_Free(byterangeString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
commandString.Append(")");
|
||||||
|
break;
|
||||||
|
case kMIMEHeader:
|
||||||
|
commandString.Append(" %s (BODY[%s.MIME])");
|
||||||
|
break;
|
||||||
};
|
};
|
||||||
|
|
||||||
commandString.Append(CRLF);
|
commandString.Append(CRLF);
|
||||||
|
|
||||||
// since messageIds can be infinitely long, use a dynamic buffer rather than the fixed one
|
// since messageIds can be infinitely long, use a dynamic buffer rather than the fixed one
|
||||||
const char *commandTag = GetServerCommandTag();
|
const char *commandTag = GetServerCommandTag();
|
||||||
int protocolStringSize = commandString.Length() + strlen(messageIds) + PL_strlen(commandTag) + 1 +
|
int protocolStringSize = commandString.Length() + strlen(messageIds) + PL_strlen(commandTag) + 1 +
|
||||||
(part ? PL_strlen(part) : 0);
|
(part ? PL_strlen(part) : 0);
|
||||||
char *protocolString = (char *) PR_CALLOC( protocolStringSize );
|
char *protocolString = (char *) PR_CALLOC( protocolStringSize );
|
||||||
|
|
||||||
if (protocolString)
|
if (protocolString)
|
||||||
{
|
{
|
||||||
char *cCommandStr = ToNewCString(commandString);
|
char *cCommandStr = ToNewCString(commandString);
|
||||||
|
@ -3028,31 +3030,31 @@ nsImapProtocol::FetchMessage(const char * messageIds,
|
||||||
(whatToFetch == kMIMEHeader))
|
(whatToFetch == kMIMEHeader))
|
||||||
{
|
{
|
||||||
PR_snprintf(protocolString, // string to create
|
PR_snprintf(protocolString, // string to create
|
||||||
protocolStringSize, // max size
|
protocolStringSize, // max size
|
||||||
cCommandStr, // format string
|
cCommandStr, // format string
|
||||||
commandTag, // command tag
|
commandTag, // command tag
|
||||||
messageIds,
|
messageIds,
|
||||||
part);
|
part);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PR_snprintf(protocolString, // string to create
|
PR_snprintf(protocolString, // string to create
|
||||||
protocolStringSize, // max size
|
protocolStringSize, // max size
|
||||||
cCommandStr, // format string
|
cCommandStr, // format string
|
||||||
commandTag, // command tag
|
commandTag, // command tag
|
||||||
messageIds);
|
messageIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult rv = SendData(protocolString);
|
nsresult rv = SendData(protocolString);
|
||||||
|
|
||||||
nsMemory::Free(cCommandStr);
|
nsMemory::Free(cCommandStr);
|
||||||
if (NS_SUCCEEDED(rv))
|
if (NS_SUCCEEDED(rv))
|
||||||
ParseIMAPandCheckForNewMail(protocolString);
|
ParseIMAPandCheckForNewMail(protocolString);
|
||||||
PR_Free(protocolString);
|
PR_Free(protocolString);
|
||||||
GetServerStateParser().SetFetchingFlags(PR_FALSE);
|
GetServerStateParser().SetFetchingFlags(PR_FALSE);
|
||||||
GetServerStateParser().SetFetchingEverythingRFC822(PR_FALSE); // always clear this flag after every fetch....
|
GetServerStateParser().SetFetchingEverythingRFC822(PR_FALSE); // always clear this flag after every fetch....
|
||||||
if (GetServerStateParser().LastCommandSuccessful() && CheckNeeded())
|
if (GetServerStateParser().LastCommandSuccessful() && CheckNeeded())
|
||||||
Check();
|
Check();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
HandleMemoryFailure();
|
HandleMemoryFailure();
|
||||||
|
|
Загрузка…
Ссылка в новой задаче