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

[tor-commits] [metrics-lib/master] Allow underscore in transport names.



commit 7b026cf44ac775a990e42762c1151f973832ca8a
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date:   Tue Jul 22 09:21:00 2014 +0200

    Allow underscore in transport names.
    
    Example of a valid line that is now allowed:
    
    bridge-ip-transports meek=32,obfs3_websocket=8,websocket=64
---
 src/org/torproject/descriptor/impl/ParseHelper.java            |    2 +-
 .../descriptor/impl/ExtraInfoDescriptorImplTest.java           |    8 ++++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/org/torproject/descriptor/impl/ParseHelper.java b/src/org/torproject/descriptor/impl/ParseHelper.java
index 048225c..caec1bb 100644
--- a/src/org/torproject/descriptor/impl/ParseHelper.java
+++ b/src/org/torproject/descriptor/impl/ParseHelper.java
@@ -302,7 +302,7 @@ public class ParseHelper {
           + "index " + index + ".");
     } else if (partsNoOpt.length > index) {
       if (!commaSeparatedKeyValueListPatterns.containsKey(keyLength)) {
-        String keyPattern = "[0-9a-zA-Z?<>-]"
+        String keyPattern = "[0-9a-zA-Z?<>\\-_]"
             + (keyLength == 0 ? "+" : "{" + keyLength + "}");
         String valuePattern = "\\-?[0-9]{1,9}";
         String patternString = String.format("^%s=%s(,%s=%s)*$",
diff --git a/test/org/torproject/descriptor/impl/ExtraInfoDescriptorImplTest.java b/test/org/torproject/descriptor/impl/ExtraInfoDescriptorImplTest.java
index 12484e5..438c700 100644
--- a/test/org/torproject/descriptor/impl/ExtraInfoDescriptorImplTest.java
+++ b/test/org/torproject/descriptor/impl/ExtraInfoDescriptorImplTest.java
@@ -1369,6 +1369,7 @@ public class ExtraInfoDescriptorImplTest {
         "bridge-ip-versions v4=24.5");
   }
 
+  @Test(expected = DescriptorParseException.class)
   public void testBridgeIpTransportsDouble()
       throws DescriptorParseException {
     BridgeStatsBuilder.createWithBridgeIpTransportsLine(
@@ -1376,6 +1377,13 @@ public class ExtraInfoDescriptorImplTest {
   }
 
   @Test()
+  public void testBridgeIpTransportsUnderscore()
+      throws DescriptorParseException {
+    BridgeStatsBuilder.createWithBridgeIpTransportsLine(
+        "bridge-ip-transports meek=32,obfs3_websocket=8,websocket=64");
+  }
+
+  @Test()
   public void testRouterSignatureOpt()
       throws DescriptorParseException {
     DescriptorBuilder.createWithRouterSignatureLines("opt "

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