mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 952092 - Get rid of post data in SessionStore r=smacleod
From 243232f7d2522e82622c031923271ed76ffdc42a Mon Sep 17 00:00:00 2001
This commit is contained in:
parent
0ce5a0b636
commit
8fafa9176a
@ -842,9 +842,6 @@ pref("browser.sessionstore.resume_session_once", false);
|
||||
|
||||
// minimal interval between two save operations in milliseconds
|
||||
pref("browser.sessionstore.interval", 15000);
|
||||
// maximum amount of POSTDATA to be saved in bytes per history entry (-1 = all of it)
|
||||
// (NB: POSTDATA will be saved either entirely or not at all)
|
||||
pref("browser.sessionstore.postdata", 0);
|
||||
// on which sites to save text data, POSTDATA and cookies
|
||||
// 0 = everywhere, 1 = unencrypted sites, 2 = nowhere
|
||||
pref("browser.sessionstore.privacy_level", 0);
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
/**
|
||||
* nsISessionStore keeps track of the current browsing state - i.e.
|
||||
* tab history, cookies, scroll state, form data, POSTDATA and window features
|
||||
* tab history, cookies, scroll state, form data, and window features
|
||||
* - and allows to restore everything into one window.
|
||||
*/
|
||||
|
||||
|
@ -9,7 +9,7 @@ interface nsIDOMNode;
|
||||
|
||||
/**
|
||||
* nsISessionStore keeps track of the current browsing state - i.e.
|
||||
* tab history, cookies, scroll state, form data, POSTDATA and window features
|
||||
* tab history, cookies, scroll state, form data, and window features
|
||||
* - and allows to restore everything into one browser window.
|
||||
*
|
||||
* The nsISessionStore API operates mostly on browser windows and the tabbrowser
|
||||
|
@ -15,7 +15,7 @@ const PREF_DEFERRED = "browser.sessionstore.privacy_level_deferred";
|
||||
|
||||
// The following constants represent the different possible privacy levels that
|
||||
// can be set by the user and that we need to consider when collecting text
|
||||
// data, cookies, and POSTDATA.
|
||||
// data, and cookies.
|
||||
//
|
||||
// Collect data from all sites (http and https).
|
||||
const PRIVACY_NONE = 0;
|
||||
|
@ -13,8 +13,6 @@ const Ci = Components.interfaces;
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PrivacyLevel",
|
||||
"resource:///modules/sessionstore/PrivacyLevel.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Utils",
|
||||
"resource:///modules/sessionstore/Utils.jsm");
|
||||
|
||||
@ -22,24 +20,12 @@ function debug(msg) {
|
||||
Services.console.logStringMessage("SessionHistory: " + msg);
|
||||
}
|
||||
|
||||
// The preference value that determines how much post data to save.
|
||||
XPCOMUtils.defineLazyGetter(this, "gPostData", function () {
|
||||
const PREF = "browser.sessionstore.postdata";
|
||||
|
||||
// Observer that updates the cached value when the preference changes.
|
||||
Services.prefs.addObserver(PREF, () => {
|
||||
this.gPostData = Services.prefs.getIntPref(PREF);
|
||||
}, false);
|
||||
|
||||
return Services.prefs.getIntPref(PREF);
|
||||
});
|
||||
|
||||
/**
|
||||
* The external API exported by this module.
|
||||
*/
|
||||
this.SessionHistory = Object.freeze({
|
||||
collect: function (docShell, includePrivateData) {
|
||||
return SessionHistoryInternal.collect(docShell, includePrivateData);
|
||||
collect: function (docShell) {
|
||||
return SessionHistoryInternal.collect(docShell);
|
||||
},
|
||||
|
||||
restore: function (docShell, tabData) {
|
||||
@ -56,10 +42,8 @@ let SessionHistoryInternal = {
|
||||
*
|
||||
* @param docShell
|
||||
* The docShell that owns the session history.
|
||||
* @param includePrivateData (optional)
|
||||
* True to always include private data and skip any privacy checks.
|
||||
*/
|
||||
collect: function (docShell, includePrivateData = false) {
|
||||
collect: function (docShell) {
|
||||
let data = {entries: []};
|
||||
let isPinned = docShell.isAppTab;
|
||||
let webNavigation = docShell.QueryInterface(Ci.nsIWebNavigation);
|
||||
@ -69,7 +53,7 @@ let SessionHistoryInternal = {
|
||||
try {
|
||||
for (let i = 0; i < history.count; i++) {
|
||||
let shEntry = history.getEntryAtIndex(i, false);
|
||||
let entry = this.serializeEntry(shEntry, includePrivateData, isPinned);
|
||||
let entry = this.serializeEntry(shEntry, isPinned);
|
||||
data.entries.push(entry);
|
||||
}
|
||||
} catch (ex) {
|
||||
@ -109,13 +93,11 @@ let SessionHistoryInternal = {
|
||||
*
|
||||
* @param shEntry
|
||||
* nsISHEntry instance
|
||||
* @param includePrivateData
|
||||
* Always return privacy sensitive data (use with care).
|
||||
* @param isPinned
|
||||
* The tab is pinned and should be treated differently for privacy.
|
||||
* @return object
|
||||
*/
|
||||
serializeEntry: function (shEntry, includePrivateData, isPinned) {
|
||||
serializeEntry: function (shEntry, isPinned) {
|
||||
let entry = { url: shEntry.URI.spec };
|
||||
|
||||
// Save some bytes and don't include the title property
|
||||
@ -156,17 +138,6 @@ let SessionHistoryInternal = {
|
||||
if (x.value != 0 || y.value != 0)
|
||||
entry.scroll = x.value + "," + y.value;
|
||||
|
||||
// Collect post data for the current history entry.
|
||||
try {
|
||||
let postdata = this.serializePostData(shEntry, isPinned);
|
||||
if (postdata) {
|
||||
entry.postdata_b64 = postdata;
|
||||
}
|
||||
} catch (ex) {
|
||||
// POSTDATA is tricky - especially since some extensions don't get it right
|
||||
debug("Failed serializing post data: " + ex);
|
||||
}
|
||||
|
||||
// Collect owner data for the current history entry.
|
||||
try {
|
||||
let owner = this.serializeOwner(shEntry);
|
||||
@ -203,7 +174,7 @@ let SessionHistoryInternal = {
|
||||
break;
|
||||
}
|
||||
|
||||
children.push(this.serializeEntry(child, includePrivateData, isPinned));
|
||||
children.push(this.serializeEntry(child, isPinned));
|
||||
}
|
||||
}
|
||||
|
||||
@ -215,40 +186,6 @@ let SessionHistoryInternal = {
|
||||
return entry;
|
||||
},
|
||||
|
||||
/**
|
||||
* Serialize post data contained in the given session history entry.
|
||||
*
|
||||
* @param shEntry
|
||||
* The session history entry.
|
||||
* @param isPinned
|
||||
* Whether the docShell is owned by a pinned tab.
|
||||
* @return The base64 encoded post data.
|
||||
*/
|
||||
serializePostData: function (shEntry, isPinned) {
|
||||
let isHttps = shEntry.URI.schemeIs("https");
|
||||
if (!shEntry.postData || !gPostData ||
|
||||
!PrivacyLevel.canSave({isHttps: isHttps, isPinned: isPinned})) {
|
||||
return null;
|
||||
}
|
||||
|
||||
shEntry.postData.QueryInterface(Ci.nsISeekableStream)
|
||||
.seek(Ci.nsISeekableStream.NS_SEEK_SET, 0);
|
||||
let stream = Cc["@mozilla.org/binaryinputstream;1"]
|
||||
.createInstance(Ci.nsIBinaryInputStream);
|
||||
stream.setInputStream(shEntry.postData);
|
||||
let postBytes = stream.readByteArray(stream.available());
|
||||
let postdata = String.fromCharCode.apply(null, postBytes);
|
||||
if (gPostData != -1 &&
|
||||
postdata.replace(/^(Content-.*\r\n)+(\r\n)*/, "").length > gPostData) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// We can stop doing base64 encoding once our serialization into JSON
|
||||
// is guaranteed to handle all chars in strings, including embedded
|
||||
// nulls.
|
||||
return btoa(postdata);
|
||||
},
|
||||
|
||||
/**
|
||||
* Serialize owner data contained in the given session history entry.
|
||||
*
|
||||
@ -375,14 +312,6 @@ let SessionHistoryInternal = {
|
||||
shEntry.setScrollPosition(scrollPos[0], scrollPos[1]);
|
||||
}
|
||||
|
||||
if (entry.postdata_b64) {
|
||||
var postdata = atob(entry.postdata_b64);
|
||||
var stream = Cc["@mozilla.org/io/string-input-stream;1"].
|
||||
createInstance(Ci.nsIStringInputStream);
|
||||
stream.setData(postdata, postdata.length);
|
||||
shEntry.postData = stream;
|
||||
}
|
||||
|
||||
let childDocIdents = {};
|
||||
if (entry.docIdentifier) {
|
||||
// If we have a serialized document identifier, try to find an SHEntry
|
||||
|
@ -313,8 +313,6 @@ let Statistics = {
|
||||
subsets.DOM_STORAGE = [];
|
||||
// The subset of sessionstore.js storing form data
|
||||
subsets.FORMDATA = [];
|
||||
// The subset of sessionstore.js storing POST data in history
|
||||
subsets.POSTDATA = [];
|
||||
// The subset of sessionstore.js storing history
|
||||
subsets.HISTORY = [];
|
||||
|
||||
@ -333,9 +331,6 @@ let Statistics = {
|
||||
subsets.FORMDATA.push(value);
|
||||
// Never visit formdata, it's full of weird stuff
|
||||
return false;
|
||||
case "postdata_b64":
|
||||
subsets.POSTDATA.push(value);
|
||||
return false; // Nothing to visit anyway
|
||||
case "cookies": // Don't visit these places, they are full of weird stuff
|
||||
case "extData":
|
||||
return false;
|
||||
|
@ -9,7 +9,7 @@ let {SessionFile, TabStateCache} = tmp;
|
||||
|
||||
// Shortcuts for histogram names
|
||||
let Keys = {};
|
||||
for (let k of ["HISTORY", "FORMDATA", "OPEN_WINDOWS", "CLOSED_WINDOWS", "CLOSED_TABS_IN_OPEN_WINDOWS", "DOM_STORAGE", "POSTDATA"]) {
|
||||
for (let k of ["HISTORY", "FORMDATA", "OPEN_WINDOWS", "CLOSED_WINDOWS", "CLOSED_TABS_IN_OPEN_WINDOWS", "DOM_STORAGE"]) {
|
||||
Keys[k] = "FX_SESSION_RESTORE_TOTAL_" + k + "_SIZE_BYTES";
|
||||
}
|
||||
|
||||
|
@ -3408,13 +3408,6 @@
|
||||
"n_buckets": 30,
|
||||
"description": "The subset of sessionstore.js dealing with storing history (total size, in bytes)"
|
||||
},
|
||||
"FX_SESSION_RESTORE_TOTAL_POSTDATA_SIZE_BYTES": {
|
||||
"expires_in_version": "never",
|
||||
"kind": "exponential",
|
||||
"high": "50000000",
|
||||
"n_buckets": 30,
|
||||
"description": "The subset of sessionstore.js dealing with storing POST data (total size, in bytes)"
|
||||
},
|
||||
"FX_SESSION_RESTORE_INDIVIDUAL_OPEN_WINDOWS_SIZE_BYTES": {
|
||||
"expires_in_version": "never",
|
||||
"kind": "exponential",
|
||||
@ -3464,13 +3457,6 @@
|
||||
"n_buckets": 30,
|
||||
"description": "The subset of sessionstore.js dealing with storing history (item size, in bytes)"
|
||||
},
|
||||
"FX_SESSION_RESTORE_INDIVIDUAL_POSTDATA_SIZE_BYTES": {
|
||||
"expires_in_version": "never",
|
||||
"kind": "exponential",
|
||||
"high": "5000000",
|
||||
"n_buckets": 30,
|
||||
"description": "The subset of sessionstore.js dealing with storing history POST data (item size, in bytes)"
|
||||
},
|
||||
"INNERWINDOWS_WITH_MUTATION_LISTENERS": {
|
||||
"expires_in_version": "never",
|
||||
"kind": "boolean",
|
||||
|
Loading…
Reference in New Issue
Block a user