Bug 409174 - View page info -> Security: doesn't show cookies were set for sites with ip:8080 address. r=florian & mano; a=mconnor

This commit is contained in:
dwitte@stanford.edu 2008-01-08 17:41:17 -08:00
parent d575b60e46
commit 220e96b5cc

View File

@ -138,10 +138,16 @@ var security = {
var win = wm.getMostRecentWindow("Browser:Cookies");
var eTLDService = Components.classes["@mozilla.org/network/effective-tld-service;1"].
getService(Components.interfaces.nsIEffectiveTLDService);
var eTLD = "";
if (this._getSecurityInfo().hostName)
eTLD = eTLDService.getBaseDomainFromHost(this._getSecurityInfo().hostName);
var eTLD;
var uri = gDocument.documentURIObject;
try {
eTLD = eTLDService.getBaseDomain(uri);
}
catch (e) {
// getBaseDomain will fail if the host is an IP address or is empty
eTLD = uri.asciiHost;
}
if (win) {
win.gCookiesWindow.setFilter(eTLD);
@ -233,10 +239,11 @@ function securityOnLoad() {
var yesStr = pageInfoBundle.getString("yes");
var noStr = pageInfoBundle.getString("no");
var uri = gDocument.documentURIObject;
setText("security-privacy-cookies-value",
hostHasCookies(info.hostName) ? yesStr : noStr);
hostHasCookies(uri) ? yesStr : noStr);
setText("security-privacy-passwords-value",
realmHasPasswords(info.fullLocation) ? yesStr : noStr);
realmHasPasswords(uri) ? yesStr : noStr);
var visitCount = previousVisitCount(info.hostName);
if(visitCount > 1) {
@ -313,30 +320,23 @@ function viewCertHelper(parent, cert)
}
/**
* Return true iff we have cookies for hostName
* Return true iff we have cookies for uri
*/
function hostHasCookies(hostName) {
if (!hostName)
return false;
function hostHasCookies(uri) {
var cookieManager = Components.classes["@mozilla.org/cookiemanager;1"]
.getService(Components.interfaces.nsICookieManager2);
return cookieManager.countCookiesFromHost(hostName) > 0;
return cookieManager.countCookiesFromHost(uri.asciiHost) > 0;
}
/**
* Return true iff realm (proto://host:port) (extracted from location) has
* Return true iff realm (proto://host:port) (extracted from uri) has
* saved passwords
*/
function realmHasPasswords(location) {
if (!location)
return false;
var realm = makeURI(location).prePath;
function realmHasPasswords(uri) {
var passwordManager = Components.classes["@mozilla.org/login-manager;1"]
.getService(Components.interfaces.nsILoginManager);
return passwordManager.countLogins(realm, "", "");
return passwordManager.countLogins(uri.prePath, "", "") > 0;
}
/**