[or-cvs] r20190: {torbutton} Fix bug #1040: Make a log scrubber so that Mac OS users don' (in torbutton/trunk/src: chrome/content components)

mikeperry at seul.org mikeperry at seul.org
Wed Jul 29 02:44:50 UTC 2009


Author: mikeperry
Date: 2009-07-28 22:44:50 -0400 (Tue, 28 Jul 2009)
New Revision: 20190

Modified:
   torbutton/trunk/src/chrome/content/torbutton.js
   torbutton/trunk/src/chrome/content/torbutton_util.js
   torbutton/trunk/src/components/cssblocker.js
   torbutton/trunk/src/components/torbutton-logger.js
   torbutton/trunk/src/components/window-mapper.js
Log:

Fix bug #1040: Make a log scrubber so that Mac OS users don't
log random urls to disk in console.log.



Modified: torbutton/trunk/src/chrome/content/torbutton.js
===================================================================
--- torbutton/trunk/src/chrome/content/torbutton.js	2009-07-29 01:20:56 UTC (rev 20189)
+++ torbutton/trunk/src/chrome/content/torbutton.js	2009-07-29 02:44:50 UTC (rev 20190)
@@ -3030,7 +3030,9 @@
                 if(doc && doc.location && 
                   (doc.location.href.indexOf("about:") != 0 &&
                    doc.location.href.indexOf("chrome:") != 0)) {
-                    torbutton_eclog(4, "Exception on tag application at "+doc.location+": "+e);
+                    torbutton_safelog(4, "Exception "+e
+                                   +" on tag application at: ",
+                                    doc.location);
                 } else {
                     torbutton_eclog(3, "Got an about url: "+e);
                 }

Modified: torbutton/trunk/src/chrome/content/torbutton_util.js
===================================================================
--- torbutton/trunk/src/chrome/content/torbutton_util.js	2009-07-29 01:20:56 UTC (rev 20189)
+++ torbutton/trunk/src/chrome/content/torbutton_util.js	2009-07-29 02:44:50 UTC (rev 20190)
@@ -4,7 +4,11 @@
 
 function torbutton_eclog(nLevel, sMsg) {
     m_tb_torlog.eclog(nLevel, sMsg);
+    return true;
+}
 
+function torbutton_safelog(nLevel, sMsg, scrub) {
+    m_tb_torlog.safe_log(nLevel, sMsg, scrub);
     return true;
 }
 

Modified: torbutton/trunk/src/components/cssblocker.js
===================================================================
--- torbutton/trunk/src/components/cssblocker.js	2009-07-29 01:20:56 UTC (rev 20189)
+++ torbutton/trunk/src/components/cssblocker.js	2009-07-29 02:44:50 UTC (rev 20190)
@@ -179,7 +179,8 @@
                                       contentLocation.spec);
                     return ok;
                 }
-                this.logger.eclog(4, "NO ORIGIN! Blockng request for: "+contentLocation.spec);
+                this.logger.safe_log(4, "NO ORIGIN! Blockng request for: ", 
+                        contentLocation.spec);
                 return block;
             }
         } else {
@@ -221,9 +222,9 @@
                 } else {
                     if (this.block_tor_file_net && this.tor_enabling ||
                             this.block_nontor_file_net && !this.tor_enabling) {
-                        this.logger.eclog(4, "Blocking remote request from: " +
-                                          requestOrigin.spec + " for: " +
-                                          contentLocation.spec);
+                        this.logger.safe_log(4, "Blocking remote request from: ",
+                                 requestOrigin.spec+" for: "
+                                 +contentLocation.spec);
                         return block;
                     }
                 }
@@ -231,7 +232,7 @@
             case "moz-nullprincipal":
                 // forbidden
                 if (this.tor_enabling) {
-                    this.logger.eclog(4, "Blocking request from: " +
+                    this.logger.safe_log(4, "Blocking request from: ",
                                       requestOrigin.spec + " for: " +
                                       contentLocation.spec);
                     return block;
@@ -245,7 +246,7 @@
                         try {
                             targetHost = contentLocation.host;
                         } catch(e) {
-                            this.logger.eclog(4, "No host from: " +
+                            this.logger.safe_log(4, "No host from: ",
                                     requestOrigin.spec + " for: " +
                                     contentLocation.spec);
                         }
@@ -260,8 +261,9 @@
                         return ok;
                     } else {
                         if (this.tor_enabling || (targetHost in protectedChromeHosts)) {
-                            this.logger.eclog(4, "Blocking local request from: "
-                                              +requestOrigin.spec+" ("
+                            this.logger.safe_log(4, 
+                                    "Blocking local request from: ",
+                                              requestOrigin.spec+" ("
                                               +requestOrigin.scheme+") for: "+
                                               contentLocation.spec);
                             return block;
@@ -285,13 +287,15 @@
             // could handle it either here or shouldProcess, instead of in 
             // the webprogresslistener
             if(this.tor_enabling && this.no_tor_plugins) {
-                this.logger.log(4, "Blocking object at "+contentLocation.spec);
+                this.logger.safe_log(4, "Blocking object at ",
+                                     contentLocation.spec);
                 return block;
             }
         }
 
         if (!wind || !wind.top.location || !wind.top.location.href) {
-            this.logger.log(4, "Skipping no location: "+contentLocation.spec);
+            this.logger.safe_log(4, "Skipping no location: ",
+                                 contentLocation.spec);
 			return ok;
         }
 
@@ -350,14 +354,14 @@
                     if(!requestOrigin.schemeIs("chrome")) {
                         if(typeof(browser.__tb_tor_fetched) == 'undefined') {
                             // This happens for "open in new window" context menu
-                            this.logger.log(3, "Untagged window for redirect "+contentLocation.spec);
+                            this.logger.safe_log(3, "Untagged window for redirect: ", contentLocation.spec);
                             return ok;
                         }
                         if(browser.__tb_tor_fetched == this.tor_enabled
                                 && browser.__tb_tor_fetched == this.settings_applied) {
                             return ok;
                         } else {
-                            this.logger.log(4, "Blocking redirect: "+contentLocation.spec);
+                            this.logger.safe_log(4, "Blocking redirect: ", contentLocation.spec);
                             return block;
                         }
                     }
@@ -370,7 +374,8 @@
                 && browser.__tb_tor_fetched == this.settings_applied) {
             return ok;
         } else {
-            this.logger.log(4, "Blocking cross state load of: "+contentLocation.spec);
+            this.logger.safe_log(4, "Blocking cross-state load of: ",
+                          contentLocation.spec);
             return block;
         }
 	},

Modified: torbutton/trunk/src/components/torbutton-logger.js
===================================================================
--- torbutton/trunk/src/components/torbutton-logger.js	2009-07-29 01:20:56 UTC (rev 20189)
+++ torbutton/trunk/src/components/torbutton-logger.js	2009-07-29 02:44:50 UTC (rev 20190)
@@ -109,6 +109,14 @@
       }
   },
 
+  safe_log: function(level, str, scrub) {
+      if (this.loglevel < 4) {
+          this.eclog(level, str+scrub);
+      } else {
+          this.eclog(level, str+" [scrubbed]");
+      }
+  },
+
   log: function(level, str) {
       switch(this.logmethod) {
           case 2: // debuglogger

Modified: torbutton/trunk/src/components/window-mapper.js
===================================================================
--- torbutton/trunk/src/components/window-mapper.js	2009-07-29 01:20:56 UTC (rev 20189)
+++ torbutton/trunk/src/components/window-mapper.js	2009-07-29 02:44:50 UTC (rev 20190)
@@ -143,9 +143,9 @@
       try {
           if(topContentWindow.name != "speedDialLoaderBrowser") {
               if(topContentWindow && topContentWindow.location)
-                  this.logger.log(4, "No browser found: "+topContentWindow.location);
+                  this.logger.safe_log(4, "No browser found: ", topContentWindow.location);
               else
-                  this.logger.log(4, "No browser found: "+topContentWindow.name);
+                  this.logger.safe_log(4, "No browser found: ", topContentWindow.name);
           } else {
               this.logger.log(3, "SpeedDial browser found: "+topContentWindow.name);
           }



More information about the tor-commits mailing list