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

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

commit 90aa824aa607148e43f170b7025af41531dab788
Author: Quan Tran <[email protected]>
AuthorDate: Wed Nov 4 21:39:00 2026 +0700

    [FIX] IPAddr: no trailing dot on an address
    
    IPAddr.getAddress, and so isIPAddr, removed a trailing dot before
    reading an address, as for a domain name: "192.0.2.1." and "::." were
    read as 192.0.2.1 and ::. No address is written with a trailing dot
    (RFC 791, RFC 4291 2.2). The a mechanism took such a target for that
    address until the previous commit; isIPAddr and getAddress are public.
    
    Read the address as given: an address with a trailing dot is invalid,
    and so is one with spaces around it, which the removed stripDot also
    trimmed (no caller in jSPF gives one). The ip4 and ip6 mechanisms
    already rejected both.
---
 resolver/src/main/java/org/apache/james/jspf/core/IPAddr.java     | 1 -
 resolver/src/test/java/org/apache/james/jspf/core/IPAddrTest.java | 3 +++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/resolver/src/main/java/org/apache/james/jspf/core/IPAddr.java 
b/resolver/src/main/java/org/apache/james/jspf/core/IPAddr.java
index 83ec242..e3d49bb 100644
--- a/resolver/src/main/java/org/apache/james/jspf/core/IPAddr.java
+++ b/resolver/src/main/java/org/apache/james/jspf/core/IPAddr.java
@@ -205,7 +205,6 @@ public class IPAddr {
      *             on error
      */
     private void stringToInternal(String netAddress) throws PermErrorException 
{
-        netAddress = stripDot(netAddress);
         // createByteArrayFromIPAddressString expects a valid address: it 
fails on "" or "[", ignores
         // a group without ":" or "." ("2" read as ::), and writes past its 
array on too many groups
         if (!isValidIP(netAddress)) {
diff --git a/resolver/src/test/java/org/apache/james/jspf/core/IPAddrTest.java 
b/resolver/src/test/java/org/apache/james/jspf/core/IPAddrTest.java
index e66213d..3214eb9 100644
--- a/resolver/src/test/java/org/apache/james/jspf/core/IPAddrTest.java
+++ b/resolver/src/test/java/org/apache/james/jspf/core/IPAddrTest.java
@@ -73,6 +73,9 @@ public class IPAddrTest extends TestCase {
         assertFalse(IPAddr.isIPAddr("2"));
         assertFalse(IPAddr.isIPAddr("1:2:3:4:5:6:7:8:9"));
         assertFalse(IPAddr.isIPAddr("1.2.3.4.5"));
+        // RFC 791, RFC 4291 2.2: no trailing dot, as in a domain name
+        assertFalse(IPAddr.isIPAddr("192.0.2.1."));
+        assertFalse(IPAddr.isIPAddr("::."));
         assertTrue(IPAddr.isIPAddr("192.0.2.1"));
         assertTrue(IPAddr.isIPAddr("2001:db8::1"));
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to