if (!cookieInList->isSession && nsInt64(cookieInList->expires) < currentTime) {
if (!cookieInList->isSession && nsInt64(cookieInList->expires) <= currentTime) {
COOKIE_GetCookie(nsIURI *aHostURI,                 nsIURI *aFirstURI){  if (!aHostURI) {    COOKIE_LOGFAILURE(GET_COOKIE, nsnull, "", "host URI is null");    return nsnull;  }  // check default prefs  nsCookieStatus cookieStatus = cookie_CheckPrefs(aHostURI, aFirstURI, nsnull, nsnull);  // for GetCookie(), we don't update the UI icon if cookie was rejected.  if (cookieStatus == nsICookie::STATUS_REJECTED) {    return nsnull;  }  // get host and path from the nsIURI  // note: there was a "check if host has embedded whitespace" here.  // it was removed since this check was added into the nsIURI impl (bug 146094).  nsCAutoString hostFromURI, pathFromURI;  if (NS_FAILED(aHostURI->GetAsciiHost(hostFromURI)) ||      NS_FAILED(aHostURI->GetPath(pathFromURI))) {    COOKIE_LOGFAILURE(GET_COOKIE, aHostURI, "", "couldn't get host/path from URI");    return nsnull;  }  // trim trailing dots  hostFromURI.Trim(".");  ToLowerCase(hostFromURI);  // initialize variables used in the list traversal  nsInt64 currentTime = NOW_IN_SECONDS;  cookie_CookieStruct *cookieInList;  // initialize string for return data  nsCAutoString cookieData;  // check if aHostURI is using an https secure protocol.  // if it isn't, then we can't send a secure cookie over the connection.  // if SchemeIs fails, assume an insecure connection, to be on the safe side  PRBool isSecure;  if NS_FAILED(aHostURI->SchemeIs("https", &isSecure)) {    isSecure = PR_FALSE;  }  // begin sCookieList traversal  PRInt32 count = sCookieList->Count();  for (PRInt32 i = 0; i < count; ++i) {    cookieInList = NS_STATIC_CAST(cookie_CookieStruct*, sCookieList->ElementAt(i));    NS_ASSERTION(cookieInList, "corrupt cookie list");    // if the cookie is secure and the host scheme isn't, we can't send it    if (cookieInList->isSecure & !isSecure) {      continue;    }    // check if the host is in the cookie's domain    // (taking into account whether it's a domain cookie)    if (!cookie_IsInDomain(cookieInList->host, hostFromURI, cookieInList->isDomain)) {      continue;    }    // calculate cookie path length, excluding trailing '/'    PRUint32 cookiePathLen = cookieInList->path.Length();    if (cookiePathLen > 0 && cookieInList->path.Last() == '/') {      --cookiePathLen;    }    // the cookie list is in order of path length; longest to shortest.    // if the nsIURI path is shorter than the cookie path, then we know the path    // isn't on the cookie path.    if (!Substring(pathFromURI, 0, cookiePathLen).Equals(Substring(cookieInList->path, 0, cookiePathLen))) {      continue;    }    if (pathFromURI.Length() > cookiePathLen &&        !ispathdelimiter(pathFromURI.CharAt(cookiePathLen))) {      /*       * |ispathdelimiter| tests four cases: '/', '?', '#', and ';'.       * '/' is the "standard" case; the '?' test allows a site at host/abc?def       * to receive a cookie that has a path attribute of abc.  this seems       * strange but at least one major site (citibank, bug 156725) depends       * on it.  The test for # and ; are put in to proactively avoid problems       * with other sites - these are the only other chars allowed in the path.       */      continue;    }    // check if the cookie has expired, and remove if so.    // note that we do this *after* previous tests passed - so we're only removing    // the ones that are relevant to this particular search.    if (!cookieInList->isSession && nsInt64(cookieInList->expires) < currentTime) {      sCookieList->RemoveElementAt(i--); // decrement i so next cookie isn't skipped      --count; // update the count      delete cookieInList;      sCookieChanged = PR_TRUE;      continue;    }    // all checks passed - update lastAccessed stamp of cookie    cookieInList->lastAccessed = currentTime;    // check if we have anything to write    if (!cookieInList->name.IsEmpty() || !cookieInList->cookie.IsEmpty()) {      // if we've already added a cookie to the return list, append a "; " so      // that subsequent cookies are delimited in the final list.      if (!cookieData.IsEmpty()) {        cookieData += NS_LITERAL_CSTRING("; ");      }      // NOTE: we used to have an #ifdef PREVENT_DUPLICATE_NAMES here,      // which would prevent multiple cookies with the same name being sent (i.e.      // only the first instance is sent). This wasn't invoked in our previous code,      // and RFC2109 implicitly allows duplicate names, so I've removed it.      if (!cookieInList->name.IsEmpty()) {        // we have a cookie->name and cookie->cookie - write both        cookieData += cookieInList->name + NS_LITERAL_CSTRING("=") + cookieInList->cookie;      } else {        // just write cookie->cookie        cookieData += cookieInList->cookie;      }    }  } // for()  // it's wasteful to alloc a new string; but we have no other choice, until we  // fix the callers to use nsACStrings.  if (!cookieData.IsEmpty()) {    COOKIE_LOGSUCCESS(GET_COOKIE, aHostURI, cookieData, nsnull);    return ToNewCString(cookieData);  }  return nsnull;}