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 f4c1112810fd936a4ba89f27c1af018fff11c98d
Author: Quan Tran <[email protected]>
AuthorDate: Fri Oct 30 16:49:19 2026 +0700

    [FIX] AMechanism.toString: write the ip6 CIDR length
    
    The ip6-cidr-length was written with the ip4 one: a//64 was printed
    as a//32 and mx:example.com/24//64 as mx:example.com/24//24, so the
    printed record parses back to other networks.
---
 .../org/apache/james/jspf/terms/AMechanism.java    |  2 +-
 .../apache/james/jspf/terms/AMechanismTest.java    | 39 ++++++++++++++++++++++
 2 files changed, 40 insertions(+), 1 deletion(-)

diff --git a/resolver/src/main/java/org/apache/james/jspf/terms/AMechanism.java 
b/resolver/src/main/java/org/apache/james/jspf/terms/AMechanism.java
index 416a458..2a60e90 100644
--- a/resolver/src/main/java/org/apache/james/jspf/terms/AMechanism.java
+++ b/resolver/src/main/java/org/apache/james/jspf/terms/AMechanism.java
@@ -222,7 +222,7 @@ public class AMechanism extends GenericMechanism implements 
SPFCheckerDNSRespons
             res.append("/"+getIp4cidr());
         }
         if (getIp6cidr() != 128) {
-            res.append("//"+getIp4cidr());
+            res.append("//"+getIp6cidr());
         }
         return res.toString();
     }
diff --git 
a/resolver/src/test/java/org/apache/james/jspf/terms/AMechanismTest.java 
b/resolver/src/test/java/org/apache/james/jspf/terms/AMechanismTest.java
new file mode 100644
index 0000000..6835a21
--- /dev/null
+++ b/resolver/src/test/java/org/apache/james/jspf/terms/AMechanismTest.java
@@ -0,0 +1,39 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.jspf.terms;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.james.jspf.impl.DefaultTermsFactory;
+import org.apache.james.jspf.parser.RFC4408SPF1Parser;
+import org.junit.Test;
+
+public class AMechanismTest {
+
+    @Test
+    public void toStringShouldWriteTheIp6CidrLength() throws Exception {
+        String directives = new RFC4408SPF1Parser(new DefaultTermsFactory())
+            .parse("v=spf1 a//64 a/24//0 mx:example.com/24//64 -all")
+            .getDirectives()
+            .toString();
+
+        assertEquals("[a//64, a/24//0, mx:example.com/24//64, -all]", 
directives);
+    }
+}


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

Reply via email to