Bug 567726 - Port Bug 561702 [sessionstore should not use RegExp static state] to SeaMonkey. r=Neil, sr=Neil
authorMisak Khachatryan <misak.bugzilla@gmail.com>
Mon, 24 May 2010 15:14:44 +0500
changeset 5729 23551ff0a6af23c6e15817015af594236b6cb8cf
parent 5728 24fd84018f885e194947b55ed253607b79df3ba3
child 5730 c5bd60ab7eacbe35926e32d4163d2086fd88b7c1
push idunknown
push userunknown
push dateunknown
reviewersNeil, Neil
bugs567726, 561702
Bug 567726 - Port Bug 561702 [sessionstore should not use RegExp static state] to SeaMonkey. r=Neil, sr=Neil
suite/common/src/nsSessionStore.js
--- a/suite/common/src/nsSessionStore.js
+++ b/suite/common/src/nsSessionStore.js
@@ -1521,23 +1521,24 @@ SessionStoreService.prototype = {
    *        Window reference
    */
   _updateCookieHosts: function sss_updateCookieHosts(aWindow) {
     var hosts = this._windows[aWindow.__SSi]._hosts = {};
 
     // get the host for each URL
     var _this = this;
     function extractHosts(aEntry) {
-      if (/^https?:\/\/(?:[^@\/\s]+@)?([\w.-]+)/.test(aEntry.url)) {
-        if (!hosts[RegExp.$1] && _this._checkPrivacyLevel(_this._getURIFromString(aEntry.url).schemeIs("https"))) {
-          hosts[RegExp.$1] = true;
+      var match = /^https?:\/\/(?:[^@\/\s]+@)?([\w.-]+)/.exec(aEntry.url);
+      if (match) {
+        if (!hosts[match[1]] && _this._checkPrivacyLevel(_this._getURIFromString(aEntry.url).schemeIs("https"))) {
+          hosts[match[1]] = true;
         }
       }
-      else if (/^file:\/\/([^\/]*)/.test(aEntry.url)) {
-        hosts[RegExp.$1] = true;
+      else if ((match = /^file:\/\/([^\/]*)/.exec(aEntry.url)) != null) {
+        hosts[match[1]] = true;
       }
       if (aEntry.children) {
         aEntry.children.forEach(extractHosts);
       }
     }
 
     this._windows[aWindow.__SSi].tabs.forEach(function(aTabData) { aTabData.entries.forEach(extractHosts); });
   },
@@ -2204,18 +2205,19 @@ SessionStoreService.prototype = {
       if (aData.innerHTML) {
         aWindow.setTimeout(function() {
           if (aContent.document.designMode == "on" &&
               hasExpectedURL(aContent.document, aData.url)) {
             aContent.document.body.innerHTML = aData.innerHTML;
           }
         }, 0);
       }
-      if (aData.scroll && /(\d+),(\d+)/.test(aData.scroll)) {
-        aContent.scrollTo(RegExp.$1, RegExp.$2);
+      var match;
+      if (aData.scroll && (match = /(\d+),(\d+)/.exec(aData.scroll)) != null) {
+        aContent.scrollTo(match[1], match[2]);
       }
       Array.forEach(aContent.document.styleSheets, function(aSS) {
         aSS.disabled = aSS.title && aSS.title != selectedPageStyle;
       });
       for (var i = 0; i < aContent.frames.length; i++) {
         if (aData.children && aData.children[i] &&
           hasExpectedURL(aContent.document, aData.url)) {
           restoreTextDataAndScrolling(aContent.frames[i], aData.children[i], aPrefix + i + "|");