summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mailman/rules/dmarc.py7
-rw-r--r--src/mailman/rules/tests/test_dmarc.py17
2 files changed, 18 insertions, 6 deletions
diff --git a/src/mailman/rules/dmarc.py b/src/mailman/rules/dmarc.py
index 890fe9ff2..26f1183e6 100644
--- a/src/mailman/rules/dmarc.py
+++ b/src/mailman/rules/dmarc.py
@@ -51,11 +51,8 @@ def _get_suffixes(url):
elog.error('Unable to retrieve data from %s: %s', url, e.reason)
return
for line in d.readlines():
- line = str(line, encoding='utf-8')
- if not line.strip() or line.startswith(' ') or line.startswith('//'):
- continue
- line = re.sub(' .*', '', line.strip())
- if not line:
+ line = str(line, encoding='utf-8').strip()
+ if not line or line.startswith(' ') or line.startswith('//'):
continue
parts = line.lower().split('.')
if parts[0].startswith('!'):
diff --git a/src/mailman/rules/tests/test_dmarc.py b/src/mailman/rules/tests/test_dmarc.py
index a486ad57a..13b9d5173 100644
--- a/src/mailman/rules/tests/test_dmarc.py
+++ b/src/mailman/rules/tests/test_dmarc.py
@@ -21,8 +21,11 @@ organizational domain tests."""
from contextlib import ExitStack
from dns.rdatatype import TXT
from dns.resolver import NXDOMAIN, NoAnswer
+from mailman.app.lifecycle import create_list
+from mailman.interfaces.mailinglist import DMARCMitigateAction
from mailman.rules import dmarc
-from mailman.testing.helpers import LogFileMark
+from mailman.testing.helpers import (
+ LogFileMark, specialized_message_from_string as mfs)
from mailman.testing.layers import ConfigLayer
from public import public
from unittest import TestCase
@@ -132,3 +135,15 @@ class TestDMARCRules(TestCase):
'https://publicsuffix.org/list/public_suffix_list.dat: '
'no internet\n')
self.assertEqual(domain, 'kobe.jp')
+
+ def test_no_at_sign_in_from_address(self):
+ # If there's no @ sign in the From: address, the rule can't hit.
+ mlist = create_list('ant@example.com')
+ mlist.dmarc_mitigate_action = DMARCMitigateAction.munge_from
+ msg = mfs("""\
+From: anne
+To: ant@example.com
+
+""")
+ rule = dmarc.DMARCMitigation()
+ self.assertFalse(rule.check(mlist, msg, {}))