[tor-commits] [tor-launcher/master] Bug #9445: Tor Launcher should be more relaxed about bridge line input.

brade at torproject.org brade at torproject.org
Thu Aug 29 19:14:54 UTC 2013


commit 6c064c5c652ec104ca600e9609ec53e6400ef9db
Author: Kathy Brade <brade at pearlcrescent.com>
Date:   Thu Aug 29 15:09:50 2013 -0400

    Bug #9445: Tor Launcher should be more relaxed about bridge line input.
    
    Spaces are no longer turned into linebreaks.
    The "bridge" prefix is optional, but it is always added for display
    purposes.
---
 src/chrome/content/network-settings.js    |   38 +++++++++++++++++------------
 src/chrome/locale/en/network-settings.dtd |    2 +-
 2 files changed, 24 insertions(+), 16 deletions(-)

diff --git a/src/chrome/content/network-settings.js b/src/chrome/content/network-settings.js
index bd0114e..35a1165 100644
--- a/src/chrome/content/network-settings.js
+++ b/src/chrome/content/network-settings.js
@@ -613,7 +613,7 @@ function initBridgeSettings()
   if (!gProtocolSvc.TorCommandSucceeded(bridgeReply))
     return false;
 
-  setElemValue(kBridgeList, bridgeReply.lineArray);
+  setBridgeListElemValue(bridgeReply.lineArray);
 
   return true;
 }
@@ -828,7 +828,7 @@ function getAndValidateBridgeSettings()
     return null;
   }
 
-  setElemValue(kBridgeList, bridgeList);
+  setBridgeListElemValue(bridgeList);
   if (useBridges && bridgeList)
   {
     settings[kTorConfKeyUseBridges] = true;
@@ -856,19 +856,7 @@ function parseAndValidateBridges(aStr)
   for (var i = 0; i < tmpArray.length; i++)
   {
     let s = tmpArray[i].trim(); // Remove extraneous whitespace.
-    if (s.indexOf(' ') >= 0)
-    {
-      // Handle a space-separated list of bridge specs.
-      var tmpArray2 = s.split(' ');
-      for (var j = 0; j < tmpArray2.length; ++j)
-      {
-        let s2 = tmpArray2[j];
-        if (s2.length > 0)
-          resultArray.push(s2);
-      }
-    }
-    else if (s.length > 0)
-      resultArray.push(s);
+    resultArray.push(s);
   }
 
   return (0 == resultArray.length) ? null : resultArray;
@@ -963,6 +951,26 @@ function setElemValue(aID, aValue)
 }
 
 
+function setBridgeListElemValue(aBridgeArray)
+{
+  // To be consistent with bridges.torproject.org, pre-pend "bridge" to
+  // each line as it is displayed in the UI.
+  var bridgeList = [];
+  for (var i = 0; i < aBridgeArray.length; ++i)
+  {
+    var s = aBridgeArray[i].trim();
+    if (s.length > 0)
+    {
+      if (s.toLowerCase().indexOf("bridge") != 0)
+        s = "bridge " + s;
+      bridgeList.push(s);
+    }
+  }
+
+  setElemValue(kBridgeList, bridgeList);
+}
+
+
 // Returns a Boolean (for checkboxes/radio buttons) or a
 // string (textbox and menulist).
 // Leading and trailing white space is trimmed from strings.
diff --git a/src/chrome/locale/en/network-settings.dtd b/src/chrome/locale/en/network-settings.dtd
index 7923622..6ca8f2a 100644
--- a/src/chrome/locale/en/network-settings.dtd
+++ b/src/chrome/locale/en/network-settings.dtd
@@ -43,7 +43,7 @@
 <!ENTITY torsettings.firewall.checkbox "This computer goes through a firewall that only allows connections to certain ports">
 <!ENTITY torsettings.firewall.allowedPorts "Allowed Ports:">
 <!ENTITY torsettings.useBridges.checkbox "My Internet Service Provider (ISP) blocks connections to the Tor network">
-<!ENTITY torsettings.useBridges.label "Enter one or more bridge relays in the form address:port.">
+<!ENTITY torsettings.useBridges.label "Enter one or more bridge relays (one per line).">
 <!ENTITY torsettings.useBridges.placeholder "address:port">
 
 <!ENTITY torsettings.copyLog "Copy Tor Log To Clipboard">



More information about the tor-commits mailing list