if (NS_FAILED(address->SchemeIs("ftp", &isFtp)) || isFtp) return nsnull;
if (NS_FAILED(address->SchemeIs("ftp", &isFtp)) || isFtp) { #if defined(PR_LOGGING) cookie_LogFailure(GET_COOKIE, address, "", "ftp sites cannot read cookies"); #endif return nsnull; }
COOKIE_GetCookie(nsIURI * address) {  char *name=0;  cookie_CookieStruct * cookie_s;  PRBool isSecure = PR_TRUE;  time_t cur_time = get_current_time();  /* return string to build */  char * rv=0;  /* disable cookies if the user's prefs say so */  if(cookie_GetBehaviorPref() == PERMISSION_DontUse) {    return nsnull;  }  /* Is this an https "secure" cookie? */  if NS_FAILED(address->SchemeIs("https", &isSecure))      isSecure = PR_TRUE;  /* Don't let ftp sites read cookies (could be a security issue) */  PRBool isFtp;  if (NS_FAILED(address->SchemeIs("ftp", &isFtp)) || isFtp)      return nsnull;  /* search for all cookies */  if (cookie_list == nsnull) {    return nsnull;  }  nsCAutoString host, path;  // Get host and path  nsresult result = address->GetHost(host);  if (NS_FAILED(result)) {    return nsnull;  }  if ((host.RFindChar(' ') != -1) || (host.RFindChar('\t') != -1)) {    return nsnull;  }  result = address->GetPath(path);  if (NS_FAILED(result)) {    return nsnull;  }  for (PRInt32 i = 0; i <cookie_list->Count(); i++) {    cookie_s = NS_STATIC_CAST(cookie_CookieStruct*, cookie_list->ElementAt(i));    NS_ASSERTION(cookie_s, "corrupt cookie list");    if(!cookie_s->host) continue;    /* check the host or domain first */    if(cookie_s->isDomain) {      if(!cookie_IsInDomain(cookie_s->host, (char*)host.get())) {        continue;      }    } else if(PL_strcasecmp(host.get(), cookie_s->host)) {      /* hostname matchup failed. FAIL */      continue;    }    /* shorter strings always come last so there can be no ambiquity */    int cookiePathLen = PL_strlen(cookie_s->path);    if (cookiePathLen > 0 && cookie_s->path[cookiePathLen-1] == '/') {      cookiePathLen--;    }    if(cookie_s->path && !PL_strncmp(path.get(), cookie_s->path, cookiePathLen)) {      PRUint32 pathLen = path.Length();      if (pathLen>cookiePathLen &&           path[cookiePathLen] != '/' && path[cookiePathLen] != '?' &&          path[cookiePathLen] != '#' && path[cookiePathLen] != ';') {        /*         * note that the '?' test above 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.         */        continue;      }      /* if the cookie is secure and the path isn't, dont send it */      if (cookie_s->isSecure & !isSecure) {        continue; /* back to top of while */      }      /* check for expired cookies */      if( cookie_s->expires && (cookie_s->expires < cur_time) ) {        /* expire and remove the cookie */        cookie_list->RemoveElementAt(i--); /* decr i so next cookie isn't skipped */        deleteCookie((void*)cookie_s, nsnull);        cookie_changed = PR_TRUE;        continue;      }      /* if we've already added a cookie to the return list, append a "; " so       * subsequent cookies are delimited in the final list. */      if (rv) CKutil_StrAllocCat(rv, "; ");      if(cookie_s->name && *cookie_s->name != '\0') {        cookie_s->lastAccessed = cur_time;        CKutil_StrAllocCopy(name, cookie_s->name);        CKutil_StrAllocCat(name, "=");#ifdef PREVENT_DUPLICATE_NAMES        /* make sure we don't have a previous name mapping already in the string */        if(!rv || !PL_strstr(rv, name)) {          CKutil_StrAllocCat(rv, name);          CKutil_StrAllocCat(rv, cookie_s->cookie);        }#else        CKutil_StrAllocCat(rv, name);        CKutil_StrAllocCat(rv, cookie_s->cookie);#endif /* PREVENT_DUPLICATE_NAMES */      } else {        CKutil_StrAllocCat(rv, cookie_s->cookie);      }    }  }  PR_FREEIF(name);  /* may be nsnull */  return(rv);}