You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by bt...@apache.org on 2019/11/22 01:47:02 UTC

[james-project] 03/03: JAMES-2986 NetMatcher's comma-separation requires space to be present

This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 73c23f13dbc33d17dfede456ffc12a5cec11963d
Author: Joerg Thomas <jo...@consol.de>
AuthorDate: Tue Nov 19 17:29:38 2019 +0100

    JAMES-2986 NetMatcher's comma-separation requires space to be present
---
 .../apache/james/dnsservice/library/netmatcher/NetMatcher.java |  4 ++--
 .../james/dnsservice/library/netmatcher/NetMatcherTest.java    | 10 ++++++++++
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/server/dns-service/dnsservice-library/src/main/java/org/apache/james/dnsservice/library/netmatcher/NetMatcher.java b/server/dns-service/dnsservice-library/src/main/java/org/apache/james/dnsservice/library/netmatcher/NetMatcher.java
index e512fbf..38f92b9 100644
--- a/server/dns-service/dnsservice-library/src/main/java/org/apache/james/dnsservice/library/netmatcher/NetMatcher.java
+++ b/server/dns-service/dnsservice-library/src/main/java/org/apache/james/dnsservice/library/netmatcher/NetMatcher.java
@@ -44,7 +44,7 @@ import com.google.common.base.Splitter;
 public class NetMatcher {
     private static final Logger LOGGER = LoggerFactory.getLogger(NetMatcher.class);
 
-    public static final String NETS_SEPARATOR = ", ";
+    public static final String NETS_SEPARATOR = ",";
 
     /**
      * The DNS Service used to build InetNetworks.
@@ -84,7 +84,7 @@ public class NetMatcher {
 
     public NetMatcher(String commaSeparatedNets, DNSService dnsServer) {
         this.dnsServer = dnsServer;
-        List<String> nets = Splitter.on(NETS_SEPARATOR).splitToList(commaSeparatedNets);
+        List<String> nets = Splitter.on(NETS_SEPARATOR).trimResults().splitToList(commaSeparatedNets);
         initInetNetworks(nets);
     }
 
diff --git a/server/dns-service/dnsservice-library/src/test/java/org/apache/james/dnsservice/library/netmatcher/NetMatcherTest.java b/server/dns-service/dnsservice-library/src/test/java/org/apache/james/dnsservice/library/netmatcher/NetMatcherTest.java
index b185cf0..dbea721 100644
--- a/server/dns-service/dnsservice-library/src/test/java/org/apache/james/dnsservice/library/netmatcher/NetMatcherTest.java
+++ b/server/dns-service/dnsservice-library/src/test/java/org/apache/james/dnsservice/library/netmatcher/NetMatcherTest.java
@@ -34,6 +34,16 @@ public class NetMatcherTest {
     private static NetMatcher netMatcher;
 
     /**
+     * Test ability to split expressions even when comma is not followed by a space.
+     */
+    @Test
+    public void testSplitterDoesNotRequireSpaceAfterComma() {
+        netMatcher = new NetMatcher("127.0.0.1,192.168.100.14/24,10.*", DNSFixture.DNS_SERVER_IPV4_MOCK);
+        assertThat(netMatcher.toString())
+                .isEqualTo("[10.0.0.0/255.0.0.0, 127.0.0.1/255.255.255.255, 192.168.100.0/255.255.255.0]");
+    }
+
+    /**
      * Test for IPV4 uniqueness.
      */
     @Test


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org