[Pkg-mozext-commits] [perspectives-extension] 01/44: Fixing extension. preference variables prefix and enshortening init code in initialize.xul

David Prévot taffit at moszumanska.debian.org
Sun Jun 26 04:59:17 UTC 2016


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository perspectives-extension.

commit 66256c673e24df8c28360e40a7abb0350861e9e4
Author: Alexey Vesnin <serxis at gmail.com>
Date:   Wed May 13 02:11:22 2015 -0700

    Fixing extension. preference variables prefix and enshortening init code in initialize.xul
    
    minor conflict resolution by dave during cherrypick
---
 plugin/chrome/content/common.js              |  4 +--
 plugin/chrome/content/init.js                |  7 +++--
 plugin/chrome/content/notaries.js            | 40 ++++++++++++++--------------
 plugin/chrome/content/preferences_dialog.js  | 18 ++++++-------
 plugin/chrome/content/preferences_dialog.xul | 20 +++++++-------
 plugin/chrome/content/report.js              | 31 +++++++++------------
 plugin/chrome/content/whitelist_dialog.js    |  8 +++---
 plugin/defaults/preferences/prefs.js         | 36 ++++++++++++-------------
 8 files changed, 78 insertions(+), 86 deletions(-)

diff --git a/plugin/chrome/content/common.js b/plugin/chrome/content/common.js
index b215e65..91649b5 100644
--- a/plugin/chrome/content/common.js
+++ b/plugin/chrome/content/common.js
@@ -238,7 +238,7 @@ var Pers_util = {
         			Pers_debug.d_print("error", "Signature verification failed on notary list update");
 				return;
 			}
-			root_prefs.setCharPref("perspectives.default_notary_list",notary_list_data);
+			root_prefs.setCharPref("extensions.perspectives.default_notary_list",notary_list_data);
 		} catch(e) {
 			if(Perspectives.strbundle == null) {
 				Perspectives.strbundle = document.getElementById("notary_strings");
@@ -253,7 +253,7 @@ var Pers_util = {
 	update_default_notary_list_from_file : function(root_prefs) {
 		try {
 			var notary_list_data = this.readFileFromURI("chrome://perspectives/content/http_notary_list.txt");
-			root_prefs.setCharPref("perspectives.default_notary_list",notary_list_data);
+			root_prefs.setCharPref("extensions.perspectives.default_notary_list",notary_list_data);
 		} catch(e) {
 			if(Perspectives.strbundle == null) {
 				Perspectives.strbundle = document.getElementById("notary_strings");
diff --git a/plugin/chrome/content/init.js b/plugin/chrome/content/init.js
index e70df90..70f24af 100644
--- a/plugin/chrome/content/init.js
+++ b/plugin/chrome/content/init.js
@@ -31,9 +31,9 @@ var Pers_init = {
       // so we have access to the stringbundle from statusbar.xul
       Perspectives.prompt_update();
 
-      var firstrun = root_prefs.getBoolPref("perspectives.first_run");
+      var firstrun = root_prefs.getBoolPref("extensions.perspectives.first_run");
       if (firstrun) {
-          root_prefs.setBoolPref("perspectives.first_run", false);
+          root_prefs.setBoolPref("extensions.perspectives.first_run", false);
           var bname = "perspectives-status-button";
 
           if (!document.getElementById(bname)) {
@@ -44,9 +44,8 @@ var Pers_init = {
           // we don't want to touch it
       }
 
-      if(!Perspectives.root_prefs.getBoolPref("perspectives.show_label")){
+      if(!Perspectives.root_prefs.getBoolPref("extensions.perspectives.show_label")){
         document.getElementById("perspective-statusbar-label").hidden = true;
       }
     }
 };
-   
diff --git a/plugin/chrome/content/notaries.js b/plugin/chrome/content/notaries.js
index 065012c..fe936c5 100644
--- a/plugin/chrome/content/notaries.js
+++ b/plugin/chrome/content/notaries.js
@@ -239,18 +239,18 @@ var Perspectives = {
 	getNotaryList: function() {
 		var all_notaries = [];
 		try {
-			var list_txt = Perspectives.root_prefs.getCharPref("perspectives.additional_notary_list");
+			var list_txt = Perspectives.root_prefs.getCharPref("extensions.perspectives.additional_notary_list");
 			var additional_notaries = Pers_util.loadNotaryListFromString(list_txt);
 			all_notaries = all_notaries.concat(additional_notaries);
 		} catch(e) {
 			Pers_debug.d_print("error", "Error parsing additional notaries: " + e);
 		}
 
-		var use_default_notaries = Perspectives.root_prefs.getBoolPref("perspectives.use_default_notary_list");
+		var use_default_notaries = Perspectives.root_prefs.getBoolPref("extensions.perspectives.use_default_notary_list");
 		if(use_default_notaries) {
 			try {
 				var default_notaries = Pers_util.loadNotaryListFromString(
-					Perspectives.root_prefs.getCharPref("perspectives.default_notary_list"));
+					Perspectives.root_prefs.getCharPref("extensions.perspectives.default_notary_list"));
 				all_notaries = all_notaries.concat(default_notaries);
 			} catch(e) {
 				Pers_debug.d_print("error", "Error parsing default notaries: " + e);
@@ -463,7 +463,7 @@ var Perspectives = {
 		//FIXME: we can cache the value inside getNotaryList() if calling is too slow.
 		var notary_count = this.getNotaryList().length;
 		var q_thresh = Perspectives.root_prefs.
-				getIntPref("perspectives.quorum_thresh") / 100;
+				getIntPref("extensions.perspectives.quorum_thresh") / 100;
 		var q_count = Math.round(notary_count * q_thresh);
 
 		if(q_count < MIN_NOTARY_COUNT) {
@@ -512,9 +512,9 @@ var Perspectives = {
 			var is_cur_consistent = quorum_duration !== -1;
 
 			var weak_check_time_limit = Perspectives.root_prefs.
-						getIntPref("perspectives.weak_consistency_time_limit");
+						getIntPref("extensions.perspectives.weak_consistency_time_limit");
 			var inconsistent_check_max = Perspectives.root_prefs.
-					getIntPref("perspectives.max_timespan_for_inconsistency_test");
+					getIntPref("extensions.perspectives.max_timespan_for_inconsistency_test");
 			var is_inconsistent = Pers_client_policy.inconsistency_check(server_result_list,
 							inconsistent_check_max, weak_check_time_limit);
 			var weakly_seen = Pers_client_policy.key_weakly_seen_by_quorum(test_key,
@@ -542,7 +542,7 @@ var Perspectives = {
 					": \n" + obs_text + "\n";
 			//Pers_debug.d_print("main","\n" + str + "\n");
 			var required_duration = Perspectives.root_prefs.
-								getIntPref("perspectives.required_duration");
+								getIntPref("extensions.perspectives.required_duration");
 			var svg = Pers_gen.get_svg_graph(ti.service_id, server_result_list, 30,
 				unixtime, test_key, max_stale_sec);
 			ti.query_results = new Perspectives.SslCert(ti.uri.host,
@@ -638,7 +638,7 @@ var Perspectives = {
 		Pers_debug.d_print("main",
 			"is_override_cert = " + ti.is_override_cert);
 		var check_good = Perspectives.root_prefs.
-			getBoolPref("perspectives.check_good_certificates");
+			getBoolPref("extensions.perspectives.check_good_certificates");
 
 
 		// see if the browser has this cert installed prior to this browser session
@@ -650,7 +650,7 @@ var Perspectives = {
 			var text = Perspectives.strbundle.
 				getFormattedString("configuredToWhitelistWithHost", [ti.uri.host]);
 			if(! (ti.already_trusted || ti.is_override_cert)) {
-				var isTemp = !Perspectives.root_prefs.getBoolPref("perspectives.exceptions.permanent");
+				var isTemp = !Perspectives.root_prefs.getBoolPref("extensions.perspectives.exceptions.permanent");
 				setTimeout(function() {
 					if(Perspectives.do_override(ti.browser, ti.cert, isTemp)) {
 						Perspectives.setFaviconText(text);
@@ -702,7 +702,7 @@ var Perspectives = {
 		} else {
 			Pers_debug.d_print("main", ti.uri.host + " needs a request");
 			var needs_perm = Perspectives.root_prefs
-					.getBoolPref("perspectives.require_user_permission");
+					.getBoolPref("extensions.perspectives.require_user_permission");
 
 			if(needs_perm && !ti.has_user_permission) {
 				Pers_debug.d_print("main", "needs user permission");
@@ -767,12 +767,12 @@ var Perspectives = {
 			}
 			var required_duration   =
 				Perspectives.root_prefs.
-					getIntPref("perspectives.required_duration");
+					getIntPref("extensions.perspectives.required_duration");
 
 			var strong_trust = ti.query_results.cur_consistent &&
 						(ti.query_results.duration >= required_duration);
 			var pref_https_weak = Perspectives.root_prefs.
-					getBoolPref("perspectives.trust_https_with_weak_consistency");
+					getBoolPref("extensions.perspectives.trust_https_with_weak_consistency");
 			var weak_trust = ti.query_results.inconsistent_results && ti.query_results.weakly_seen;
 
 			if(strong_trust) {
@@ -780,11 +780,11 @@ var Perspectives = {
 				var mixed_security =  ti.state & Perspectives.state.STATE_IS_BROKEN;
 				if(!ti.is_override_cert && (ti.state & Perspectives.state.STATE_IS_INSECURE)) {
 					ti.exceptions_enabled = Perspectives.root_prefs.
-						getBoolPref("perspectives.exceptions.enabled");
+						getBoolPref("extensions.perspectives.exceptions.enabled");
 					if(ti.exceptions_enabled) {
 						ti.override_used = true;
 						var isTemp = !Perspectives.root_prefs.
-							getBoolPref("perspectives.exceptions.permanent");
+							getBoolPref("extensions.perspectives.exceptions.permanent");
 						Perspectives.do_override(ti.browser, ti.cert, isTemp);
 						ti.query_results.identityText = Perspectives.strbundle.
 							getString("exceptionAdded");
@@ -897,7 +897,7 @@ var Perspectives = {
 		try {
 			/* be cautious in case we got a bad user edit to the whitelist */
 			var whitelist = Perspectives.root_prefs.
-				    getCharPref("perspectives.whitelist").split(",");
+				    getCharPref("extensions.perspectives.whitelist").split(",");
 			for(var entry in whitelist) {
 				if(whitelist.hasOwnProperty(entry)) {
 					var e = whitelist[entry];
@@ -1021,7 +1021,7 @@ var Perspectives = {
 		try {
 			Pers_debug.d_print("main", "\nPerspectives Initialization\n");
 
-			var auto_update = this.root_prefs.getBoolPref("perspectives.enable_default_list_auto_update");
+			var auto_update = this.root_prefs.getBoolPref("extensions.perspectives.enable_default_list_auto_update");
 			if(auto_update) {
 				Pers_util.update_default_notary_list_from_web(this.root_prefs);
 			} else {
@@ -1127,12 +1127,12 @@ var Perspectives = {
 
 			//'prompt_update_all_https_setting' stores a value for "have we already asked the user about this?"
 			var ask_update = Perspectives.root_prefs.
-	                getBoolPref("perspectives.prompt_update_all_https_setting");
+	                getBoolPref("extensions.perspectives.prompt_update_all_https_setting");
 
 			if(ask_update === true) {
 
 				var check_good = Perspectives.root_prefs.
-						getBoolPref("perspectives.check_good_certificates");
+						getBoolPref("extensions.perspectives.check_good_certificates");
 
 				if(!check_good) {
 
@@ -1156,7 +1156,7 @@ var Perspectives = {
 						"", null, check);
 					if(answer === 0) {
 						Perspectives.root_prefs.
-							setBoolPref("perspectives.check_good_certificates",
+							setBoolPref("extensions.perspectives.check_good_certificates",
 										true);
 					}
 				}
@@ -1170,7 +1170,7 @@ var Perspectives = {
 			//this way even in the worst case the user will only get a popup once.
 			//they can always change their preferences later through the prefs dialog if they wish.
 			Perspectives.root_prefs.
-						setBoolPref("perspectives.prompt_update_all_https_setting",
+						setBoolPref("extensions.perspectives.prompt_update_all_https_setting",
 									false);
 		}
 	}
diff --git a/plugin/chrome/content/preferences_dialog.js b/plugin/chrome/content/preferences_dialog.js
index acf3cab..d747549 100644
--- a/plugin/chrome/content/preferences_dialog.js
+++ b/plugin/chrome/content/preferences_dialog.js
@@ -96,7 +96,7 @@ var Pers_pref = {
 				}
 			});
 
-			return [ {pref: "perspectives.whitelist"                    , value: whitelist_enabled .join(",")}
+			return [ {pref: "extensions.perspectives.whitelist"                    , value: whitelist_enabled .join(",")}
 				   , {pref: "extensions.perspectives.whitelist_disabled", value: whitelist_disabled.join(",")}
 				   ];
 		},
@@ -176,8 +176,8 @@ var Pers_pref = {
 		var ret = true;
 
 		try {
-			if (this.root_prefs.getIntPref("perspectives.required_duration") < 0) {
-				this.root_prefs.setIntPref("perspectives.required_duration", 0);
+			if (this.root_prefs.getIntPref("extensions.perspectives.required_duration") < 0) {
+				this.root_prefs.setIntPref("extensions.perspectives.required_duration", 0);
 			}
 		} catch (e) {
 			Pers_util.pers_alert(e);
@@ -185,10 +185,10 @@ var Pers_pref = {
 		}
 
 		try {
-			if (this.root_prefs.getIntPref("perspectives.quorum_thresh") < 1) {
-				this.root_prefs.setIntPref("perspectives.quorum_thresh", 1);
-			} else if (this.root_prefs.getIntPref("perspectives.quorum_thresh") > 100) {
-				this.root_prefs.setIntPref("perspectives.quorum_thresh", 100);
+			if (this.root_prefs.getIntPref("extensions.perspectives.quorum_thresh") < 1) {
+				this.root_prefs.setIntPref("extensions.perspectives.quorum_thresh", 1);
+			} else if (this.root_prefs.getIntPref("extensions.perspectives.quorum_thresh") > 100) {
+				this.root_prefs.setIntPref("extensions.perspectives.quorum_thresh", 100);
 			}
 		} catch (e) {
 			Pers_util.pers_alert(e);
@@ -239,12 +239,12 @@ var Pers_pref = {
 			Pers_pref.security_class_change();
 			Pers_pref.disable_reminder_box();
 
-			var whitelist          = this.root_prefs.getCharPref("perspectives.whitelist");
+			var whitelist          = this.root_prefs.getCharPref("extensions.perspectives.whitelist");
 			var whitelist_disabled = this.root_prefs.getCharPref("extensions.perspectives.whitelist_disabled");
 			Pers_pref.whitelist_treeView.init(whitelist, whitelist_disabled);
 			document.getElementById('whitelist').view = Pers_pref.whitelist_treeView;
 
-			document.getElementById("default_notary_list").value = this.root_prefs.getCharPref("perspectives.default_notary_list");
+			document.getElementById("default_notary_list").value = this.root_prefs.getCharPref("extensions.perspectives.default_notary_list");
 		} catch(e) {
 			Pers_util.pers_alert(e);
 		}
diff --git a/plugin/chrome/content/preferences_dialog.xul b/plugin/chrome/content/preferences_dialog.xul
index c433675..778ac9a 100644
--- a/plugin/chrome/content/preferences_dialog.xul
+++ b/plugin/chrome/content/preferences_dialog.xul
@@ -16,11 +16,11 @@
         <preferences>
             <preference
                     id  ="quorum-thresh"
-                    name="perspectives.quorum_thresh"
+                    name="extensions.perspectives.quorum_thresh"
                     type="int"/>
             <preference
                     id  ="quorum-duration"
-                    name="perspectives.required_duration"
+                    name="extensions.perspectives.required_duration"
                     type="int"/>
             <preference
                     id  ="query-timeout"
@@ -36,23 +36,23 @@
                     type="int"/>
             <preference
                     id  ="security-settings"
-                    name="perspectives.security_settings"
+                    name="extensions.perspectives.security_settings"
                     type="int"/>
             <preference
                     id  ="exception-perm"
-                    name="perspectives.exceptions.permanent"
+                    name="extensions.perspectives.exceptions.permanent"
                     type="bool"/>
             <preference
                     id  ="exception-enabled"
-                    name="perspectives.exceptions.enabled"
+                    name="extensions.perspectives.exceptions.enabled"
                     type="bool"/>
             <preference
                     id  ="check-good"
-                    name="perspectives.check_good_certificates"
+                    name="extensions.perspectives.check_good_certificates"
                     type="bool"/>
             <preference
                     id  ="require-user-permission"
-                    name="perspectives.require_user_permission"
+                    name="extensions.perspectives.require_user_permission"
                     type="bool"/>
             <preference
                     id  ="show-permission-reminder"
@@ -64,15 +64,15 @@
                     type="bool"/>
             <preference
                     id  ="additional_notary_list"
-                    name="perspectives.additional_notary_list"
+                    name="extensions.perspectives.additional_notary_list"
                     type="string"/>
             <preference
                     id  ="use-default-notary-list"
-                    name="perspectives.use_default_notary_list"
+                    name="extensions.perspectives.use_default_notary_list"
                     type="bool"/>
             <preference
                     id  ="enable-default-list-auto-update"
-                    name="perspectives.enable_default_list_auto_update"
+                    name="extensions.perspectives.enable_default_list_auto_update"
                     type="bool"/>
         </preferences>
 
diff --git a/plugin/chrome/content/report.js b/plugin/chrome/content/report.js
index 8d7e88a..ffb3cf3 100644
--- a/plugin/chrome/content/report.js
+++ b/plugin/chrome/content/report.js
@@ -34,26 +34,19 @@ var Pers_report = {
         // before turning it back on.
         return ips;
     },  
- 
-    get_ip_str : function(hostname) {
-        var ips    = this.get_ips(hostname);
-        var ip_str = "";
-
-        if (ips.length <= 0 ) {
-            return ip_str;
-        }
-
-        ip_str = ips[0];
 
-        if (ips.length == 1) {
-            return ip_str;
-        }
-
-        for (var i = 1; i < ips.length; i++) {
-            ip_str= ip_str + "," + ips[i];
-        }
-
-        return ip_str;
+    get_ip_str : function(hostname) {
+	var suffixes=[".onion",".i2p"];
+	var needResolve=true;
+	for (index = 0; index < suffixes.length; ++index) {
+	    if(hostname.indexOf(suffixes[index], hostname.length - suffixes[index].length) !== -1){
+		// No name-to-IP resolution possible for darknet addresses
+		needResolve=false;
+	    }
+	}
+	if(needResolve){
+	    this.get_ips(hostname);
+	}
     }, 
 
     get_report_json : function() {
diff --git a/plugin/chrome/content/whitelist_dialog.js b/plugin/chrome/content/whitelist_dialog.js
index 1b1fbff..db6b7fd 100644
--- a/plugin/chrome/content/whitelist_dialog.js
+++ b/plugin/chrome/content/whitelist_dialog.js
@@ -56,13 +56,13 @@ var Pers_whitelist_dialog = {
 		} else {
 			var regex = "^" + host.replace(".","\\.","g") + "$";
 		}
-		var whitelist = this.root_prefs.getCharPref("perspectives.whitelist");
+		var whitelist = this.root_prefs.getCharPref("extensions.perspectives.whitelist");
 		if(whitelist.length == 0) {
 			whitelist = regex;
 		} else {
 			whitelist = whitelist + "," + regex;
 		}
-		this.root_prefs.setCharPref("perspectives.whitelist",whitelist);
+		this.root_prefs.setCharPref("extensions.perspectives.whitelist",whitelist);
 		window.opener.Perspectives.forceStatusUpdate(window.opener);
 		} catch(e) { Pers_util.pers_alert("confirm_add: " + e); }
 	},
@@ -141,7 +141,7 @@ var Pers_whitelist_dialog = {
 			}
 
 			var host = window.gBrowser.currentURI.host;
-			var old_whitelist = Perspectives.root_prefs.getCharPref("perspectives.whitelist").split(",");
+			var old_whitelist = Perspectives.root_prefs.getCharPref("extensions.perspectives.whitelist").split(",");
 			var new_whitelist = [];
 			for(var entry in old_whitelist) {
 				var e = old_whitelist[entry];
@@ -159,7 +159,7 @@ var Pers_whitelist_dialog = {
 				}
 				new_whitelist.push(e);
 			}
-			Perspectives.root_prefs.setCharPref("perspectives.whitelist",new_whitelist.join(","));
+			Perspectives.root_prefs.setCharPref("extensions.perspectives.whitelist",new_whitelist.join(","));
 			window.Perspectives.forceStatusUpdate(window);
 		} catch(e) { Pers_util.pers_alert("remove_from_whitelist:" + e); }
 	}
diff --git a/plugin/defaults/preferences/prefs.js b/plugin/defaults/preferences/prefs.js
index bb5c815..94baf87 100755
--- a/plugin/defaults/preferences/prefs.js
+++ b/plugin/defaults/preferences/prefs.js
@@ -1,28 +1,28 @@
 // new preference should be created in the "extensions.perspectives.x" namespace
 // see https://developer.mozilla.org/en/Extensions/Extension_etiquette
 // and https://github.com/danwent/Perspectives/issues/59
-pref("perspectives.quorum_thresh"    ,   75);
-pref("perspectives.required_duration",    0);
+pref("extensions.perspectives.quorum_thresh"    ,   75);
+pref("extensions.perspectives.required_duration",    0);
 pref("extensions.perspectives.query_timeout_ms", 5000);
 pref("extensions.perspectives.query_retries"   ,    2);
-pref("perspectives.security_settings",    1);
-pref("perspectives.exceptions.permanent", false);
-pref("perspectives.exceptions.enabled", true);
-pref("perspectives.check_good_certificates", true);
-pref("perspectives.require_user_permission", false);
+pref("extensions.perspectives.security_settings",    1);
+pref("extensions.perspectives.exceptions.permanent", false);
+pref("extensions.perspectives.exceptions.enabled", true);
+pref("extensions.perspectives.check_good_certificates", true);
+pref("extensions.perspectives.require_user_permission", false);
 pref("extensions.perspectives.show_permission_reminder", true);
 pref("extensions.perspectives.contact_in_private_browsing_mode", false);
-pref("perspectives.show_label", true);
-pref("perspectives.max_timespan_for_inconsistency_test", 7);
-pref("perspectives.weak_consistency_time_limit", 30);
-pref("perspectives.trust_https_with_weak_consistency", true);
+pref("extensions.perspectives.show_label", true);
+pref("extensions.perspectives.max_timespan_for_inconsistency_test", 7);
+pref("extensions.perspectives.weak_consistency_time_limit", 30);
+pref("extensions.perspectives.trust_https_with_weak_consistency", true);
 pref("extensions.perspectives.max_cache_age_sec", 10000);
-pref("perspectives.whitelist"                    , "");
+pref("extensions.perspectives.whitelist"                    , "");
 pref("extensions.perspectives.whitelist_disabled", "");
-pref("perspectives.prompt_update_all_https_setting", true);
-pref("perspectives.additional_notary_list", "");
-pref("perspectives.default_notary_list","");
-pref("perspectives.use_default_notary_list",true);
-pref("perspectives.enable_default_list_auto_update",false);
-pref("perspectives.first_run", true);
+pref("extensions.perspectives.prompt_update_all_https_setting", true);
+pref("extensions.perspectives.additional_notary_list", "");
+pref("extensions.perspectives.default_notary_list","");
+pref("extensions.perspectives.use_default_notary_list",true);
+pref("extensions.perspectives.enable_default_list_auto_update",false);
+pref("extensions.perspectives.first_run", true);
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/perspectives-extension.git



More information about the Pkg-mozext-commits mailing list