[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [torbutton/master] Bug 27427: Fix NoScript IPC for about:blank by whitelisting messages



commit 8ff3b44e478ebddf5a067d796f57a353beae2af0
Author: Rusty Bird <rustybird@xxxxxxxxx>
Date:   Mon Sep 3 12:32:04 2018 +0000

    Bug 27427: Fix NoScript IPC for about:blank by whitelisting messages
    
    If about:blank is the homepage (or has been passed as a command line
    parameter), NoScript will send a message named "fetchChildPolicy"
    _before_ "started". Torbutton would then send its "updateSettings" too
    soon, resulting in the dreaded error "Could not establish connection.
    Receiving end does not exist" (see bug 26520).
    
    Fix this by whitelisting the relevant messages from NoScript: "started"
    and also "pageshow" for a slightly more graceful failure mode in case
    Torbutton somehow misses NoScript startup.
---
 src/modules/noscript-control.js | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/modules/noscript-control.js b/src/modules/noscript-control.js
index 66a00528..cd1a1237 100644
--- a/src/modules/noscript-control.js
+++ b/src/modules/noscript-control.js
@@ -125,8 +125,12 @@ var initialize = () => {
 
     // Wait for the first message from NoScript to arrive, and then
     // bind the security_slider pref to the NoScript settings.
-    let messageListener = (a,b,c) => {
-      log(3, `Message received from NoScript: ${JSON.stringify([a,b,c])}`);
+    let messageListener = (message,b,c) => {
+      log(3, `Message received from NoScript: ${JSON.stringify([message,b,c])}`);
+      if (message._messageName !== "started" &&
+          message._messageName !== "pageshow") {
+        return;
+      }
       extensionContext.api.browser.runtime.onMessage.removeListener(messageListener);
       bindPrefAndInit(
         "extensions.torbutton.security_slider",

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits