Identity popup calls override service incorrectly. b=432241 r=gavin a=mconnor
authorjohnath@mozilla.com
Mon, 05 May 2008 11:06:42 -0700
changeset 14935 e144cdb3828ed307a83c38028c8cbf80df5bd246
parent 14934 bd84c3146439289e1499476f0901cec10e6d2e89
child 14936 29b1ee26714dc08c475c2db65c461e0998ca0c28
push id25
push userjorendorff@mozilla.com
push dateFri, 09 May 2008 18:10:52 +0000
treeherdermozilla-central@b7dd3823dbdd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgavin, mconnor
bugs432241
milestone1.9pre
Identity popup calls override service incorrectly. b=432241 r=gavin a=mconnor
browser/base/content/browser.js
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -4198,17 +4198,18 @@ nsBrowserStatusHandler.prototype =
 
     // Don't pass in the actual location object, since it can cause us to 
     // hold on to the window object too long.  Just pass in the fields we
     // care about. (bug 424829)
     var location = gBrowser.contentWindow.location;
     var locationObj = {};
     try {
       locationObj.host = location.host;
-      locationObj.hostname = location.hostname
+      locationObj.hostname = location.hostname;
+      locationObj.port = location.port;
     } catch (ex) {
       // Can sometimes throw if the URL being visited has no host/hostname,
       // e.g. about:blank. The _state for these pages means we won't need these
       // properties anyways, though.
     }
     getIdentityHandler().checkIdentity(this._state, locationObj);
   },
 
@@ -6437,17 +6438,17 @@ IdentityHandler.prototype = {
   
   /**
    * Determine the identity of the page being displayed by examining its SSL cert
    * (if available) and, if necessary, update the UI to reflect this.  Intended to
    * be called by onSecurityChange
    * 
    * @param PRUint32 state
    * @param JS Object location that mirrors an nsLocation (i.e. has .host and
-   *                           .hostname)
+   *                           .hostname and .port)
    */
   checkIdentity : function(state, location) {
     var currentStatus = gBrowser.securityUI
                                 .QueryInterface(Components.interfaces.nsISSLStatusProvider)
                                 .SSLStatus;
     this._lastStatus = currentStatus;
     this._lastLocation = location;
     
@@ -6530,18 +6531,23 @@ IdentityHandler.prototype = {
       if (!this._overrideService)
         this._overrideService = Components.classes["@mozilla.org/security/certoverride;1"]
                                           .getService(Components.interfaces.nsICertOverrideService);
 
       // Verifier is either the CA Org, for a normal cert, or a special string
       // for certs that are trusted because of a security exception.
       var tooltip = this._stringBundle.getFormattedString("identity.identified.verifier",
                                                           [iData.caOrg]);
+      
+      // Check whether this site is a security exception. XPConnect does the right
+      // thing here in terms of converting _lastLocation.port from string to int, but
+      // the overrideService doesn't like undefined ports, so make sure we have
+      // something in the default case (bug 432241).
       if (this._overrideService.hasMatchingOverride(this._lastLocation.hostname, 
-                                                    this._lastLocation.port, 
+                                                    (this._lastLocation.port || 443),
                                                     iData.cert, {}, {}))
         tooltip = this._stringBundle.getString("identity.identified.verified_by_you");
     }
     else if (newMode == this.IDENTITY_MODE_IDENTIFIED) {
       // If it's identified, then we can populate the dialog with credentials
       iData = this.getIdentityData();  
       tooltip = this._stringBundle.getFormattedString("identity.identified.verifier",
                                                       [iData.caOrg]);