From 2b41e68166dc061b91d6d738aea4e49ff159c6bb Mon Sep 17 00:00:00 2001 From: Andreas Gal Date: Mon, 26 Apr 2010 12:58:15 -0700 Subject: [PATCH] Bug 561702 - sessionstore should not use RegExp static state. r=zpao, a=developers --- .../sessionstore/src/nsSessionStore.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/browser/components/sessionstore/src/nsSessionStore.js b/browser/components/sessionstore/src/nsSessionStore.js index c8efbb118d0e..e59fd7e9cd8d 100644 --- a/browser/components/sessionstore/src/nsSessionStore.js +++ b/browser/components/sessionstore/src/nsSessionStore.js @@ -1639,13 +1639,14 @@ SessionStoreService.prototype = { // get the domain for each URL 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; + if ((match = /^https?:\/\/(?:[^@\/\s]+@)?([\w.-]+)/.exec(aEntry.url)) != null) { + 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); @@ -2374,8 +2375,9 @@ SessionStoreService.prototype = { } }, 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;