bug 492392 followup: strip the leading period from the cookie host when comparing it against authorized hosts so initial_persona cookies that are imported from IE (when the Firefox+Personas bundle is installed) get correctly applied; r=myk
authorJose E. Bolanos <jose@glaxstar.com>
Tue, 28 Jul 2009 18:55:50 -0700
changeset 1110 a84fe86d5d4326fece72813d6c453c065a08f8a3
parent 1104 07bba8c43117cdfdfbfcf86147cc1430b84094e9
child 1111 bd6d0bf4875db0c1fbda591d25f51543a38d6616
push id721
push usermyk@mozilla.com
push dateWed, 29 Jul 2009 02:04:35 +0000
reviewersmyk
bugs492392
bug 492392 followup: strip the leading period from the cookie host when comparing it against authorized hosts so initial_persona cookies that are imported from IE (when the Firefox+Personas bundle is installed) get correctly applied; r=myk
client/modules/service.js
--- a/client/modules/service.js
+++ b/client/modules/service.js
@@ -525,18 +525,25 @@ let PersonaService = {
     let cookieManager =
       Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager);
     let cookieEnu = cookieManager.enumerator;
     let selectedCookie = null;
 
     while (cookieEnu.hasMoreElements()) {
       let cookie = cookieEnu.getNext().QueryInterface(Ci.nsICookie);
 
+      // XXX: Remove the initial dot from the host name, if any, before it is
+      // compared against the authorized hosts. This fixes the bug reported in
+      // bug 492392 that getpersonas.com and www.getpersonas.com cookies
+      // imported from IE have the cookie host .getpersonas.com, so they didn't
+      // match any of the authorized hosts.
+      let cookieHost = cookie.host.replace(/^\./, "");
+
       if (cookie.name == "initial_persona" &&
-          authorizedHosts.some(function(v) v == cookie.host)) {
+          authorizedHosts.some(function(v) v == cookieHost)) {
 
         // There could be more than one "initial_persona" cookie. The cookie
         // with latest expiration time is selected.
         if (null == selectedCookie ||
             cookie.expires > selectedCookie.expires) {
           selectedCookie = cookie;
         }