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 281fcf3567d434699e5c7307893c6cd741132c04
Author: Quan Tran <[email protected]>
AuthorDate: Fri Oct 30 16:50:21 2026 +0700

    [FIX] DNSServiceXBillImpl.getRecordsAsync: no record for an invalid name
    
    getRecords answers null, no record, for a host name dnsjava cannot parse
    (include:a..example.com), but getRecordsAsync threw
    IllegalArgumentException: the asynchronous executor gave neutral where
    the synchronous one gave permerror (RFC 7208 4.3: a malformed domain has
    no record, "none", which an include makes a permerror, 5.2).
    
    Complete the future with null, as getRecords answers.
---
 .../main/java/org/apache/james/jspf/impl/DNSServiceXBillImpl.java | 3 ++-
 .../src/test/java/org/apache/james/jspf/SPFExecutorBaseTest.java  | 8 ++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git 
a/resolver/src/main/java/org/apache/james/jspf/impl/DNSServiceXBillImpl.java 
b/resolver/src/main/java/org/apache/james/jspf/impl/DNSServiceXBillImpl.java
index 7384894..fbb8eb9 100644
--- a/resolver/src/main/java/org/apache/james/jspf/impl/DNSServiceXBillImpl.java
+++ b/resolver/src/main/java/org/apache/james/jspf/impl/DNSServiceXBillImpl.java
@@ -193,8 +193,9 @@ public class DNSServiceXBillImpl implements DNSService {
             return 
lookupSession.lookupAsync(Name.fromString(request.getHostname()), dnsJavaType)
                 .thenApply(result -> 
convertRecordsToList(result.getRecords().toArray(new Record[0])));
         } catch (TextParseException e) {
+            // no record, as getRecords answers
             LOGGER.debug("No {} Record found for host: {}", 
recordTypeDescription, request.getHostname());
-            throw new IllegalArgumentException();
+            return CompletableFuture.completedFuture(null);
         }
     }
 
diff --git 
a/resolver/src/test/java/org/apache/james/jspf/SPFExecutorBaseTest.java 
b/resolver/src/test/java/org/apache/james/jspf/SPFExecutorBaseTest.java
index 7fb0bf1..fe7710e 100644
--- a/resolver/src/test/java/org/apache/james/jspf/SPFExecutorBaseTest.java
+++ b/resolver/src/test/java/org/apache/james/jspf/SPFExecutorBaseTest.java
@@ -471,6 +471,14 @@ public abstract class SPFExecutorBaseTest {
         assertEquals(SPFErrorConstants.PERM_ERROR_CONV, result.getResult());
     }
 
+    @Test(timeout = 10000)
+    public void shouldReturnPermErrorWhenIncludeHostIsNotADomainName() throws 
IOException {
+        String hostname = "includeHostNotADomainName.spfexecutor.fake";
+        SPFResult result = checkRecord(hostname, "v=spf1 include:a.." + 
hostname + " -all", "192.0.2.127");
+
+        assertEquals(SPFErrorConstants.PERM_ERROR_CONV, result.getResult());
+    }
+
     @Test(timeout = 10000)
     public void ipv4MappedIp6NetworkShouldNotMatchAnIp4Client() throws 
IOException {
         SPFResult result = 
checkRecord("ipv4MappedIp6Network.spfexecutor.fake", "v=spf1 
ip6:::ffff:0.2.3.4/3 -all", "1.2.3.4");


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

Reply via email to