[or-cvs] r16058: Fix an issue with locale spoofing messing up addons locale i (in torbutton/trunk/src: chrome/content components)
mikeperry at seul.org
mikeperry at seul.org
Fri Jul 18 18:09:15 UTC 2008
Author: mikeperry
Date: 2008-07-18 14:09:15 -0400 (Fri, 18 Jul 2008)
New Revision: 16058
Modified:
torbutton/trunk/src/chrome/content/jshooks.js
torbutton/trunk/src/chrome/content/torbutton.js
torbutton/trunk/src/components/window-mapper.js
Log:
Fix an issue with locale spoofing messing up addons locale in
some circumstances. Also add some improved log messages and
defensive programming around untagged windows.
Modified: torbutton/trunk/src/chrome/content/jshooks.js
===================================================================
--- torbutton/trunk/src/chrome/content/jshooks.js 2008-07-18 17:13:18 UTC (rev 16057)
+++ torbutton/trunk/src/chrome/content/jshooks.js 2008-07-18 18:09:15 UTC (rev 16058)
@@ -54,6 +54,7 @@
var tmp_oscpu = window.__tb_oscpu;
var tmp_platform = window.__tb_platform;
var tmp_productSub = window.__tb_productSub;
+ var tmp_locale = window.__tb_locale;
// This is just unreasonable.. Firefox caches
// window.navigator.__proto__ between same-origin loads of a document.
@@ -82,6 +83,9 @@
})();
}
+ if(tmp_locale != false) {
+ window.navigator.__defineGetter__("language", function() { return tmp_locale;});
+ }
window.navigator.__defineGetter__("oscpu", function() { return tmp_oscpu;});
window.navigator.__defineGetter__("productSub", function() { return tmp_productSub;});
window.navigator.__defineGetter__("buildID", function() { return 0;});
Modified: torbutton/trunk/src/chrome/content/torbutton.js
===================================================================
--- torbutton/trunk/src/chrome/content/torbutton.js 2008-07-18 17:13:18 UTC (rev 16057)
+++ torbutton/trunk/src/chrome/content/torbutton.js 2008-07-18 18:09:15 UTC (rev 16058)
@@ -862,16 +862,12 @@
}
if(torprefs.getBoolPref("spoof_english") && mode) {
- m_tb_prefs.setCharPref("general.useragent.locale",
- torprefs.getCharPref("spoof_locale"));
m_tb_prefs.setCharPref("intl.accept_charsets",
torprefs.getCharPref("spoof_charset"));
m_tb_prefs.setCharPref("intl.accept_languages",
torprefs.getCharPref("spoof_language"));
} else {
try {
- if(m_tb_prefs.prefHasUserValue("general.useragent.locale"))
- m_tb_prefs.clearUserPref("general.useragent.locale");
if(m_tb_prefs.prefHasUserValue("intl.accept_charsets"))
m_tb_prefs.clearUserPref("intl.accept_charsets");
if(m_tb_prefs.prefHasUserValue("intl.accept_languages"))
@@ -1663,10 +1659,15 @@
function torbutton_check_js_tag(browser, tor_enabled, js_enabled) {
if (typeof(browser.__tb_tor_fetched) == 'undefined') {
- // FIXME: the error console is still a navigator:browser
- // and triggers this.
- // Is there any way to otherwise detect it?
- torbutton_log(5, "UNTAGGED WINDOW!!!!!!!!!");
+ try {
+ torbutton_log(5, "UNTAGGED WINDOW at: "+browser.src);
+ } catch(e) {
+ torbutton_log(5, "UNTAGGED WINDOW: "+e);
+ }
+ // Defensive programming to tag this window here to
+ // an alternate tor state. It wil lmake this window totally
+ // useless, but that is better than some undefined state
+ browser.__tb_tor_fetched = !tor_enabled;
}
if(browser.__tb_tor_fetched == tor_enabled) { // States match, js ok
@@ -2379,7 +2380,12 @@
if(typeof(browser.__tb_tor_fetched) == "undefined") {
torbutton_log(5, "Untagged browser at: "+win.location);
- } else if(browser.__tb_tor_fetched != !tor_tag) {
+ // Defensive programming to tag this window here to
+ // an alternate tor state. It wil lmake this window totally
+ // useless, but that is better than some undefined state
+ browser.__tb_tor_fetched = tor_tag;
+ }
+ if(browser.__tb_tor_fetched != !tor_tag) {
// Purge session history every time we fetch a new doc
// in a new tor state
torbutton_log(2, "Purging session history");
@@ -2489,6 +2495,11 @@
// enabled.
str2 += "window.__tb_set_uagent=false;\r\n";
}
+ if(torprefs.getBoolPref("spoof_english")) {
+ str2 += "window.__tb_locale=\""+m_tb_prefs.getCharPref('extensions.torbutton.spoof_locale')+"\";\r\n";
+ } else {
+ str2 += "window.__tb_locale=false;\r\n";
+ }
str2 += "window.__tb_oscpu=\""+m_tb_prefs.getCharPref('extensions.torbutton.oscpu_override')+"\";\r\n";
str2 += "window.__tb_platform=\""+m_tb_prefs.getCharPref('extensions.torbutton.platform_override')+"\";\r\n";
str2 += "window.__tb_productSub=\""+m_tb_prefs.getCharPref('extensions.torbutton.productsub_override')+"\";\r\n";
@@ -2657,7 +2668,11 @@
torbutton_hookdoc(DOMWindow.window, doc);
}
} catch(e) {
- torbutton_eclog(3, "Hit about:plugins? "+doc.location);
+ if(doc.location != "about:plugins") {
+ torbutton_eclog(4, "Exception on tag application at "+doc.location+": "+e);
+ } else {
+ torbutton_eclog(3, "Hit about:plugins");
+ }
}
} else {
torbutton_eclog(3, "No aProgress for location!");
Modified: torbutton/trunk/src/components/window-mapper.js
===================================================================
--- torbutton/trunk/src/components/window-mapper.js 2008-07-18 17:13:18 UTC (rev 16057)
+++ torbutton/trunk/src/components/window-mapper.js 2008-07-18 18:09:15 UTC (rev 16058)
@@ -115,6 +115,12 @@
return cached;
}
+ try {
+ this.logger.log(3, "Cache failed for: "+topContentWindow.location);
+ } catch(e) {
+ this.logger.log(3, "Cache failed for unknown location?");
+ }
+
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
var enumerator = wm.getEnumerator("navigator:browser");
More information about the tor-commits
mailing list