From b352a26a4960196066fd0f4893083dd8ac2222ec Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Wed, 16 Sep 2009 12:16:14 +1000 Subject: [PATCH] Make macros and marks sanitizeable. --- common/content/sanitizer.js | 105 ++++++++++++++++------------ vimperator/locale/en-US/options.txt | 25 ++++--- 2 files changed, 75 insertions(+), 55 deletions(-) diff --git a/common/content/sanitizer.js b/common/content/sanitizer.js index 9b8f57ac..86c7c9ff 100644 --- a/common/content/sanitizer.js +++ b/common/content/sanitizer.js @@ -27,16 +27,14 @@ the terms of any one of the MPL, the GPL or the LGPL. }}} ***** END LICENSE BLOCK *****/ // TODO: -// - should all storage items with the privateData flag be sanitizeable? i.e. -// local-marks, url-marks, quick-marks, macros. Bookmarks et al aren't -// sanitizeable in FF. +// - fix Sanitize autocommand // - add warning for TIMESPAN_EVERYTHING? // - respect privacy.clearOnShutdown et al or recommend VimperatorLeave autocommand? // - add support for :set sanitizeitems=all like 'eventignore'? // - integrate with the Clear Private Data dialog? // FIXME: -// - finish FF 3.0 support if we're going to support that in Vimperator 2.2 +// - finish 1.9.0 support if we're going to support sanitizing in Xulmus function Sanitizer() //{{{ { @@ -48,21 +46,17 @@ function Sanitizer() //{{{ services.get("subscriptLoader").loadSubScript("chrome://browser/content/sanitize.js", local); const Sanitizer = local.Sanitizer; - var prefToArgMap = { - cache: "cache", - cookies: "cookies", - offlineApps: "offlineapps", - history: "history", - formdata: "formdata", - downloads: "downloads", - passwords: "passwords", - sessions: "sessions", - siteSettings: "sitesettings", - commandLine: "commandline" - }; + var prefArgList = [["commandLine", "commandline"], + ["offlineApps", "offlineapps"], + ["siteSettings", "sitesettings"]]; - function prefToArg(pref) prefToArgMap[pref.replace(/.*\./, "")] - function argToPref(arg) [p for ([p, a] in Iterator(prefToArgMap)) if (a == arg)][0] + function prefToArg(pref) + { + let pref = pref.replace(/.*\./, ""); + return util.Array.toObject(prefArgList)[pref] || pref; + } + + function argToPref(arg) [k for ([, [k, v]] in Iterator(prefArgList)) if (v == arg)][0] || arg /////////////////////////////////////////////////////////////////////////////}}} ////////////////////// OPTIONS ///////////////////////////////////////////////// @@ -70,7 +64,7 @@ function Sanitizer() //{{{ options.add(["sanitizeitems", "si"], "The default list of private items to sanitize", - "stringlist", "history,formdata,cookies,cache,sessions,commandline", + "stringlist", "cache,commandline,cookies,formdata,history,marks,sessions", { setter: function (values) { @@ -93,15 +87,17 @@ function Sanitizer() //{{{ getter: function () sanitizer.prefNames.filter(function (pref) options.getPref(pref)).map(prefToArg).join(","), completer: function (value) [ ["cache", "Cache"], + ["commandline", "Command-line history"], ["cookies", "Cookies"], - ["offlineapps", "Offline website data"], - ["history", "Browsing history"], - ["formdata", "Saved form and search history"], ["downloads", "Download history"], + ["formdata", "Saved form and search history"], + ["history", "Browsing history"], + ["macros", "Saved macros"], + ["marks", "Local and URL marks"], + ["offlineapps", "Offline website data"], ["passwords", "Saved passwords"], ["sessions", "Authenticated sessions"], ["sitesettings", "Site preferences"], - ["commandline", "Command-line history"] ], validator: Option.validateCompleter }); @@ -210,30 +206,51 @@ function Sanitizer() //{{{ self.prefDomain = "privacy.item."; self.prefDomain2 = "extensions.liberator.privacy.cpd."; - self.items.commandLine = { - canClear: true, - clear: function () + + // add liberator-specific private items + [ { - let stores = ["command", "search"]; - - if (self.range) + name: "commandLine", + action: function () { - stores.forEach(function (store) { - storage["history-" + store].mutate("filter", function (item) { - let timestamp = item.timestamp * 1000; - return timestamp < self.range[0] || timestamp > self.range[1]; - }); - }); - } - else - stores.forEach(function (store) { storage["history-" + store].truncate(0); }); - } - }; + let stores = ["command", "search"]; - // FIXME - // create liberator-specific sanitize prefs - if (options.getPref(self.prefDomain2 + "commandLine") == null) - options.setPref(self.prefDomain2 + "commandLine", false) + if (self.range) + { + stores.forEach(function (store) { + storage["history-" + store].mutate("filter", function (item) { + let timestamp = item.timestamp * 1000; + return timestamp < self.range[0] || timestamp > self.range[1]; + }); + }); + } + else + stores.forEach(function (store) { storage["history-" + store].truncate(0); }); + } + }, + { + name: "macros", + action: function () { storage["macros"].clear(); } + }, + { + name: "marks", + action: function () + { + storage["local-marks"].clear(); + storage["url-marks"].clear(); + } + } + ].forEach(function (item) { + let pref = self.prefDomain2 + item.name; + + if (options.getPref(pref) == null) + options.setPref(pref, false); + + self.items[item.name] = { + canClear: true, + clear: item.action + } + }); self.getClearRange = Sanitizer.getClearRange; diff --git a/vimperator/locale/en-US/options.txt b/vimperator/locale/en-US/options.txt index 998fdc3c..f6a3ae80 100644 --- a/vimperator/locale/en-US/options.txt +++ b/vimperator/locale/en-US/options.txt @@ -665,23 +665,26 @@ ____ |\'si'| |\'sanitizeitems'| + -||'sanitizeitems' 'si'|| stringlist (default: "history,formdata,cookies,cache,sessions,commandline") +||'sanitizeitems' 'si'|| stringlist ____ +(default: "cache,commandline,cookies,formdata,history,marks,sessions") The default list of private items to sanitize. [frame="topbot",grid="none",cols="1,4"] |=============================================================================== -|*cache* |Cache -|*commandline* |Command-line history -|*cookies* |Cookies -|*downloads* |Download history -|*formdata* |Saved form and search history -|*history* |Browsing history -|*offlineapps* |Offline website data -|*passwords* |Saved passwords -|*sessions* |Authenticated sessions -|*sitesettings* |Site preferences +|*cache* |Cache +|*commandline* |Command-line history +|*cookies* |Cookies +|*downloads* |Download history +|*formdata* |Saved form and search history +|*history* |Browsing history +|*marks* |Local and URL marks +|*macros* |Saved macros +|*offlineapps* |Offline website data +|*passwords* |Saved passwords +|*sessions* |Authenticated sessions +|*sitesettings*|Site preferences |=============================================================================== When history items are sanitized [c]:open[c], [c]:tabopen[c] and [c]:winopen[c]