git: 16d8d1884fd7 - main - mail/py-spf-engine: Fix crash in pyspf-milter eom()

From: Jochen Neumeister <joneum_at_FreeBSD.org>
Date: Sat, 10 Oct 2026 08:34:45 UTC
The branch main has been updated by joneum:

URL: https://cgit.FreeBSD.org/ports/commit/?id=16d8d1884fd7d8085b5b5537ef18ff3bab52bb4b

commit 16d8d1884fd7d8085b5b5537ef18ff3bab52bb4b
Author:     Jochen Neumeister <joneum@FreeBSD.org>
AuthorDate: 2026-10-10 08:33:46 +0000
Commit:     Jochen Neumeister <joneum@FreeBSD.org>
CommitDate: 2026-10-10 08:34:36 +0000

    mail/py-spf-engine: Fix crash in pyspf-milter eom()
    
    eom() split the Authentication-Results header at ": " and raised a
    ValueError when the SPF engine handed it a value without that
    separator, for example when HELO_reject is No_Check and the sender is
    empty or when TestOnly is 0. pymilter turned the uncaught exception into
    a tempfail, so the message was deferred and eventually bounced.
    
    Add the header only when the separator is present and log a warning
    otherwise. The message is delivered without an Authentication-Results
    header, the envelope-stage reject decisions are not affected.
    
    PR:             296277
    Reported by:    gessel@blackrosetech.com
    Sponsored by:   Netzkommune GmbH
---
 mail/py-spf-engine/Makefile                           |  1 +
 .../files/patch-spf__engine_milter__spf.py            | 19 +++++++++++++++++--
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/mail/py-spf-engine/Makefile b/mail/py-spf-engine/Makefile
index f45227094aa9..90ad94a82cd5 100644
--- a/mail/py-spf-engine/Makefile
+++ b/mail/py-spf-engine/Makefile
@@ -1,5 +1,6 @@
 PORTNAME=	spf-engine
 DISTVERSION=	3.1.0
+PORTREVISION=	1
 CATEGORIES=	mail python
 MASTER_SITES=	PYPI
 PKGNAMEPREFIX=	${PYTHON_PKGNAMEPREFIX}
diff --git a/mail/py-spf-engine/files/patch-spf__engine_milter__spf.py b/mail/py-spf-engine/files/patch-spf__engine_milter__spf.py
index 27d525241b95..d65d52feabd1 100644
--- a/mail/py-spf-engine/files/patch-spf__engine_milter__spf.py
+++ b/mail/py-spf-engine/files/patch-spf__engine_milter__spf.py
@@ -1,6 +1,21 @@
---- spf_engine/milter_spf.py.orig	2023-01-11 14:35:12 UTC
+--- spf_engine/milter_spf.py.orig	2024-07-06 22:24:06 UTC
 +++ spf_engine/milter_spf.py
-@@ -211,7 +211,7 @@ class spfMilter(Milter.Base):
+@@ -152,8 +152,12 @@
+             h = fold(str(h))
+             if milterconfig.get('debugLevel') >= 2:
+                 syslog.syslog(str(h))
+-            name, val = str(h).split(': ', 1)
+-            self.addheader(name, val, 0)
++            name, sep, val = str(h).partition(': ')
++            if sep:
++                self.addheader(name, val, 0)
++            else:
++                syslog.syslog(syslog.LOG_WARNING,
++                    "pyspf-milter: malformed AR result, header not added: %r" % h)
+         return Milter.CONTINUE
+ 
+ 
+@@ -223,7 +227,7 @@
  def main():
      # Ugh, but there's no easy way around this.
      global milterconfig