From 2d40fb6e2888b7594f22d2bd9d27e966cf45dd12 Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Sun, 6 Sep 2009 03:20:57 +1000 Subject: [PATCH] Respect -timespan when sanitizing command-line history. --- common/content/sanitizer.js | 17 ++++++++++++++--- common/content/ui.js | 5 ++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/common/content/sanitizer.js b/common/content/sanitizer.js index a3de6a0c..eaa33379 100644 --- a/common/content/sanitizer.js +++ b/common/content/sanitizer.js @@ -30,7 +30,6 @@ the terms of any one of the MPL, the GPL or the LGPL. // - 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. -// - timestamp the command-line history? // - add warning for TIMESPAN_EVERYTHING? // - respect privacy.clearOnShutdown et al or recommend VimperatorLeave autocommand? // - add support for :set sanitizeitems=all like 'eventignore'? @@ -215,8 +214,19 @@ function Sanitizer() //{{{ canClear: true, clear: function () { - storage["history-command"].truncate(0); - storage["history-search"].truncate(0); + let stores = ["command", "search"]; + + 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); }); } }; @@ -244,6 +254,7 @@ function Sanitizer() //{{{ return branch2.getBoolPref(name); } } + // Cache the range of times to clear if (this.ignoreTimespan) var range = null; // If we ignore timespan, clear everything diff --git a/common/content/ui.js b/common/content/ui.js index 553461ea..6b3aae5c 100644 --- a/common/content/ui.js +++ b/common/content/ui.js @@ -161,8 +161,7 @@ function CommandLine() //{{{ { // Not really the ideal place for this check. if (this.mode == "command") - return (commands.get(str.replace("^[\s:]*", "").split(/[\s!]+/)[0]) || {}) - .privateData; + return (commands.get(commands.parseCommand(str)[1]) || {}).privateData; return false; }, /** @@ -170,7 +169,7 @@ function CommandLine() //{{{ */ sanitize: function () { - // TODO: Respect privacy.item.timeSpan + // TODO: Respect privacy.item.timeSpan (options["sts"]) this.store.mutate("filter", function (line) !line.privateData); }, /**