[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] [torbutton/master] Fixed some major bugs!
Author: Kory Kork <kory@xxxxxxxxxxxx>
Date: Mon, 17 Aug 2009 01:30:10 +0000
Subject: Fixed some major bugs!
Commit: f1e45caeb0877ae64fdf74dd5293cbdd31d8115d
svn:r20325
---
src/chrome/content/preferences.js | 25 +++++++++++++------------
src/chrome/content/torbutton.js | 5 ++---
src/components/cookie-jar-selector.js | 33 +++++++++++++++++++++------------
3 files changed, 36 insertions(+), 27 deletions(-)
diff --git a/src/chrome/content/preferences.js b/src/chrome/content/preferences.js
index e73f94b..5780e03 100644
--- a/src/chrome/content/preferences.js
+++ b/src/chrome/content/preferences.js
@@ -181,26 +181,27 @@ function torbutton_prefs_init(doc) {
o_torprefs.setBoolPref('tor_memory_jar', true);
doc.getElementById('torbutton_torMemoryJar').disabled = true;
doc.getElementById('torbutton_nonTorMemoryJar').disabled = false;
- } else if(o_torprefs.getBoolPref('dual_cookie_jars')) {
- doc.getElementById('torbutton_cookieGroup').selectedItem =
- doc.getElementById('torbutton_dualCookieJars');
- o_torprefs.setBoolPref('cookie_jars', false);
- o_torprefs.setBoolPref('dual_cookie_jars', true);
- o_torprefs.setBoolPref('clear_cookies', false);
- o_torprefs.setBoolPref('cookie_protections',false);
- doc.getElementById('torbutton_torMemoryJar').disabled = false;
- doc.getElementById('torbutton_nonTorMemoryJar').disabled = false;
} else if(o_torprefs.getBoolPref('cookie_protections')) {
doc.getElementById('torbutton_cookieGroup').selectedItem =
doc.getElementById('torbutton_cookieProtections');
o_torprefs.setBoolPref('cookie_jars', false);
- o_torprefs.setBoolPref('dual_cookie_jars', false);
+ o_torprefs.setBoolPref('dual_cookie_jars', true);
o_torprefs.setBoolPref('clear_cookies', false);
o_torprefs.setBoolPref('tor_memory_jar', false);
o_torprefs.setBoolPref('nontor_memory_jar', false);
doc.getElementById('torbutton_torMemoryJar').disabled = true;
doc.getElementById('torbutton_nonTorMemoryJar').disabled = true;
- } else {
+ }
+ else if(o_torprefs.getBoolPref('dual_cookie_jars')) {
+ doc.getElementById('torbutton_cookieGroup').selectedItem =
+ doc.getElementById('torbutton_dualCookieJars');
+ o_torprefs.setBoolPref('cookie_jars', false);
+ o_torprefs.setBoolPref('dual_cookie_jars', true);
+ o_torprefs.setBoolPref('clear_cookies', false);
+ o_torprefs.setBoolPref('cookie_protections',false);
+ doc.getElementById('torbutton_torMemoryJar').disabled = false;
+ doc.getElementById('torbutton_nonTorMemoryJar').disabled = false;
+ } else {
doc.getElementById('torbutton_cookieGroup').selectedItem =
doc.getElementById('torbutton_mmmCookies');
o_torprefs.setBoolPref('cookie_jars', false);
@@ -393,7 +394,7 @@ function torbutton_prefs_save(doc) {
o_torprefs.setBoolPref('block_cache', doc.getElementById('torbutton_blockCache').selected);
o_torprefs.setBoolPref('clear_cookies', doc.getElementById('torbutton_clearCookies').selected);
o_torprefs.setBoolPref('cookie_jars', doc.getElementById('torbutton_cookieJars').selected);
- o_torprefs.setBoolPref('dual_cookie_jars', doc.getElementById('torbutton_dualCookieJars').selected);
+ o_torprefs.setBoolPref('dual_cookie_jars', doc.getElementById('torbutton_dualCookieJars').selected || doc.getElementById('torbutton_cookieProtections').selected);
o_torprefs.setBoolPref('cookie_protections', doc.getElementById('torbutton_cookieProtections').selected);
o_torprefs.setBoolPref('disable_domstorage', doc.getElementById('torbutton_noDomStorage').checked);
o_torprefs.setBoolPref('clear_http_auth', doc.getElementById('torbutton_clearHttpAuth').checked);
diff --git a/src/chrome/content/torbutton.js b/src/chrome/content/torbutton.js
index b7e9e23..1ed1e79 100644
--- a/src/chrome/content/torbutton.js
+++ b/src/chrome/content/torbutton.js
@@ -1415,7 +1415,6 @@ function checkProtections()
}
function torbutton_open_cookie_dialog() {
-
window.openDialog('chrome://torbutton/content/torcookiedialog.xul','Cookie Protections',
'centerscreen,chrome,dialog,modal,resizable');
}
@@ -1569,12 +1568,12 @@ function torbutton_jar_cookies(mode) {
selector.clearUnprotectedCookies("nontor");
selector.saveCookies("nontor");
selector.clearCookies();
- if(m_tb_prefs.getBoolPref('extensions.torbutton.dual_cookie_jars') || protectcookies)
+ 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') || protectcookies)
+ if(m_tb_prefs.getBoolPref('extensions.torbutton.dual_cookie_jars'))
selector.saveCookies("tor");
selector.clearCookies();
selector.loadCookies("nontor", false);
diff --git a/src/components/cookie-jar-selector.js b/src/components/cookie-jar-selector.js
index c506ca7..4426d78 100644
--- a/src/components/cookie-jar-selector.js
+++ b/src/components/cookie-jar-selector.js
@@ -307,38 +307,47 @@ function CookieJarSelector() {
this.logger.log(2, "Cookies saved");
};
this.clearUnprotectedCookies = function(name) {
- var prompts = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
- .getService(Components.interfaces.nsIPromptService);
-
+ try {
+
var cookiesAsXml = this.getProtectedCookies(name);
if (cookiesAsXml == null)
return;//file does not exist - no protected cookies
var cookiemanager =
Cc["@mozilla.org/cookiemanager;1"]
- .getService(Ci.nsICookieManager);
+ .getService(Ci.nsICookieManager2);
var enumerator = cookiemanager.enumerator;
var count = 0;
var protcookie = false;
- prompts.alert(null, "hey", cookiesAsXml.cookie.length());
while (enumerator.hasMoreElements()) {
var nextCookie = enumerator.getNext();
+ if (!nextCookie) break;
+ nextCookie = nextCookie.QueryInterface(Components.interfaces.nsICookie);
+
+
for (var i = 0; i < cookiesAsXml.cookie.length(); i++) {
var xml = cookiesAsXml.cookie[i];
var cvalue = xml.toString();
var cname = xml.@name;
var chost = xml.@host;
var cpath = xml.@path;
- protcookie = (nextCookie.host == chost && nextCookie.name == cname && nextCookie.path == cpath)
+
+ protcookie = protcookie || (nextCookie.host == chost && nextCookie.name == cname && nextCookie.path == cpath);
}
- if (!protcookie)
- cookiemanager.remove(nextCookie.host,
+ if (!protcookie)
+ {
+ cookiemanager.remove(nextCookie.host,
nextCookie.name,
- nextCookie.path,
- false);
- protcookie = false;
- }
+ nextCookie.path, false);
+ }
+ protcookie = false;
+ }
+ }
+ catch (e)
+ {
+ this.logger.log(2, "Error deleting unprotected cookies. " + e);
+ }
}
this._oldLoadCookies = function(name, deleteSavedCookieJar) {
--
1.5.6.5