(!dispToken.EqualsIgnoreCase("inline") &&
(!dispToken.LowerCaseEqualsLiteral("inline") &&
static PRBool GetFilenameAndExtensionFromChannel(nsIChannel* aChannel,                                                 nsAString& aFileName,                                                 nsACString& aExtension,                                                 PRBool aAllowURLExtension = PR_TRUE){  /*   * If the channel is an http or part of a multipart channel and we   * have a content disposition header set, then use the file name   * suggested there as the preferred file name to SUGGEST to the   * user.  we shouldn't actually use that without their   * permission... otherwise just use our temp file   */  nsCAutoString disp;  ExtractDisposition(aChannel, disp);  PRBool handleExternally = PR_FALSE;  nsCOMPtr<nsIURI> uri;  nsresult rv;  aChannel->GetURI(getter_AddRefs(uri));  // content-disposition: has format:  // disposition-type < ; name=value >* < ; filename=value > < ; name=value >*  if (!disp.IsEmpty())   {    nsCOMPtr<nsIMIMEHeaderParam> mimehdrpar = do_GetService(NS_MIMEHEADERPARAM_CONTRACTID, &rv);    if (NS_FAILED(rv))      return PR_FALSE;    nsAutoString dispToken;    // Get the disposition type    rv = mimehdrpar->GetParameter(disp, "", EmptyCString(), PR_FALSE,                                   nsnull, dispToken);    // RFC 2183, section 2.8 says that an unknown disposition    // value should be treated as "attachment"    if (NS_FAILED(rv) ||         (!dispToken.EqualsIgnoreCase("inline") &&        // Broken sites just send        // Content-Disposition: filename="file"        // without a disposition token... screen those out.        !dispToken.EqualsIgnoreCase("filename", 8)) &&        // Also in use is Content-Disposition: name="file"        !dispToken.EqualsIgnoreCase("name", 4))     {      // We have a content-disposition of "attachment" or unknown      handleExternally = PR_TRUE;    }    // We may not have a disposition type listed; some servers suck.    // But they could have listed a filename anyway.    GetFilenameFromDisposition(aFileName, disp, uri, mimehdrpar);    // Extract Extension, if we have a filename; otherwise,    // truncate the string    if (aFileName.IsEmpty())    {      aExtension.Truncate();    }    else    {      // XXX RFindCharInReadable!!      nsAutoString fileNameStr(aFileName);      PRInt32 idx = fileNameStr.RFindChar(PRUnichar('.'));      if (idx != kNotFound)        CopyUTF16toUTF8(StringTail(fileNameStr, fileNameStr.Length() - idx - 1), aExtension);    }  } // we had a disp header   // If the disposition header didn't work, try the filename from nsIURL  nsCOMPtr<nsIURL> url(do_QueryInterface(uri));  if (url && aFileName.IsEmpty())  {    if (aAllowURLExtension)      url->GetFileExtension(aExtension);    // try to extract the file name from the url and use that as a first pass as the    // leaf name of our temp file...    nsCAutoString leafName; // may be shortened by NS_UnescapeURL    url->GetFileName(leafName);    if (!leafName.IsEmpty())    {      nsCOMPtr<nsITextToSubURI> textToSubURI = do_GetService(NS_ITEXTTOSUBURI_CONTRACTID, &rv);      if (NS_SUCCEEDED(rv))      {        nsCAutoString originCharset;        url->GetOriginCharset(originCharset);        rv = textToSubURI->UnEscapeURIForUI(originCharset, leafName,                                             aFileName);      }      if (NS_FAILED(rv))      {        CopyUTF8toUTF16(leafName, aFileName); // use escaped name      }    }  }  return handleExternally;}