Bug 567726 - Port
Bug 561702 [sessionstore should not use RegExp static state] to SeaMonkey. r=Neil, sr=Neil
--- 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 + "|");