Commit 8ddb2e92 authored by Kory Kork's avatar Kory Kork
Browse files

Auto-protect cookies works (finally)

Fake refresh feature only available through about:config
The do not write tor/non-tor cookies to disk options works now.

svn:r20457
parent 8e3fa28a
......@@ -1529,17 +1529,20 @@ function torbutton_jar_cookies(mode) {
return;
}*/
var protectcookies = m_tb_prefs.getBoolPref('extensions.torbutton.cookie_protections');
var writeTor = !m_tb_prefs.getBoolPref('extensions.torbutton.tor_memory_jar');
var writeNontor = !m_tb_prefs.getBoolPref('extensions.torbutton.nontor_memory_jar');
if(mode) {
if (protectcookies)
selector.clearUnprotectedCookies("nontor");
selector.saveCookies("nontor");
if (writeNontor)
selector.saveCookies("nontor");
selector.clearCookies();
if(m_tb_prefs.getBoolPref('extensions.torbutton.dual_cookie_jars'))
selector.loadCookies("tor", false);
} else {
if (protectcookies)
selector.clearUnprotectedCookies("tor");
if(m_tb_prefs.getBoolPref('extensions.torbutton.dual_cookie_jars'))
if(m_tb_prefs.getBoolPref('extensions.torbutton.dual_cookie_jars') && writeTor)
selector.saveCookies("tor");
selector.clearCookies();
selector.loadCookies("nontor", false);
......
......@@ -79,9 +79,7 @@ function initDialog() {
//apply custom view
cookiesTreeView.rowCount = cookies.length;
cookiesTree.treeBoxObject.view = cookiesTreeView;
//grab data from xml files
//add protected tag
document.getElementById('defaultCookieGroup').selectedIndex = prefs.getBoolPref("extensions.torbutton.cookie_auto_protect")? 0 : 1;
}
function protectCookie()
{
......@@ -134,6 +132,7 @@ function acceptDialog() {
}
selector.protectCookies(protcookies);
//output protected cookies
prefs.setBoolPref("extensions.torbutton.cookie_auto_protect",document.getElementById('saveAllCookies').selected);
}
function CookieColumnSort(column) {
lastCookieSortAscending =
......
......@@ -170,10 +170,36 @@ function CookieJarSelector() {
foStream.write(data, data.length);
foStream.close();
}
this.addProtectedCookie = function(cookie) {
var tor_enabled = this.prefs.getBoolPref("extensions.torbutton.tor_enabled");
var name = tor_enabled? "tor" : "nontor";
var cookies = this.getProtectedCookies(name);
var xml = <cookie>{cookie.value}</cookie>;
xml.@name = cookie.name;
xml.@host = cookie.host;
xml.@path = cookie.path;
if (cookie.isSecure)
xml.@isSecure = 1;
if (cookie.isSession) {
xml.@isSession = 1;
// session cookies get fucked up expiry. Give it 1yr if
// the user wants to save their session cookies
xml.@expiry = Date.now()/1000 + 365*24*60*60;
} else {
xml.@expiry = cookie.expiry;
}
if (cookie.isHttpOnly)
xml.@isHttpOnly = 1;
cookies.appendChild(xml);
this["protected-" + name] = cookies;
this._protectedCookiesToFile(name);
}
this.getProtectedCookies = function(name) {
var file = getProfileFile("protected-" + name + ".xml");
if (!file.exists())
return null;
return null;
var data = "";
var fstream = Cc["@mozilla.org/network/file-input-stream;1"]
.createInstance(Ci.nsIFileInputStream);
......@@ -501,7 +527,6 @@ CookieJarSelector.prototype =
}
return this;
},
wrappedJSObject: null, // Initialized by constructor
// make this an nsIClassInfo object
......@@ -524,7 +549,10 @@ CookieJarSelector.prototype =
observe : function(aSubject, aTopic, aData) {
switch(aTopic) {
case "cookie-changed":
var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
this.timerCallback.cookie_changed = true;
if (aData = "added" && prefs.getBoolPref("extensions.torbutton.cookie_auto_protect"))
this.addProtectedCookie(aSubject.QueryInterface(Components.interfaces.nsICookie2));//protect the new cookie!
break;
case "app-startup":
var obsSvc = Components.classes["@mozilla.org/observer-service;1"].getService(nsIObserverService);
......
......@@ -96,6 +96,7 @@ pref("extensions.torbutton.no_tor_plugins",true);
pref("extensions.torbutton.clear_cookies",false);
pref("extensions.torbutton.cookie_jars",true);
pref("extensions.torbutton.cookie_protections",false);
pref("extensions.torbutton.cookie_auto_protect",false);
pref("extensions.torbutton.dual_cookie_jars",false);
pref("extensions.torbutton.disable_domstorage",true);
pref("extensions.torbutton.clear_cache",true);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment