Skip to content

Commit

Permalink
Updated the from_headers fix based on comment from @msapiro, removed …
Browse files Browse the repository at this point in the history
…unit test (which was broken and not very relevant anyway)
  • Loading branch information
adam-iris committed Feb 25, 2020
1 parent ec2f27a commit 93bbcb9
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 21 deletions.
2 changes: 1 addition & 1 deletion authheaders/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def dmarc_per_from(from_domain, spf_result=None, dkim_result=None, dnsfunc=None,

# get from domain
headers, _ = rfc822_parse(msg)
from_headers = [a[1] for a in getaddresses(x[1].decode('utf-8') for x in headers if x[0].lower() == b"from")]
from_headers = [a[1] for a in getaddresses(x[1].decode(errors='ignore').strip() for x in headers if x[0].lower() == b"from")]

if len(from_headers) > 1:
# multi-from processing per RFC 7489 6.6.1
Expand Down
15 changes: 0 additions & 15 deletions authheaders/test/test.message_from_name

This file was deleted.

5 changes: 0 additions & 5 deletions authheaders/test/test_authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ def setUp(self):
self.message5 = read_test_data("test.message_sub")
self.message6 = read_test_data("test.message_np1")
self.message7 = read_test_data("test.message_np2")
self.message8 = read_test_data("test.message_from_name")
self.key = read_test_data("test.private")

def dnsfunc(self, domain, timeout=5):
Expand Down Expand Up @@ -120,10 +119,6 @@ def test_prev(self):
res = authenticate_message(self.message2, "example.com", prev=prev, spf=False, dmarc=False, dnsfunc=self.dnsfunc)
self.assertEqual(res, "Authentication-Results: example.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=example.com header.i=@example.com")

def test_message_from_name(self):
res = authenticate_message(self.message8, "example.com", spf=False, dmarc=False, dnsfunc=self.dnsfunc)
# This test fails!
# self.assertEqual(res, "Authentication-Results: example.com; dkim=pass header.d=example.com header.i=@example.com")

class TestChainValidation(unittest.TestCase):
def dnsfuncb(self, domain, timeout=5):
Expand Down

0 comments on commit 93bbcb9

Please sign in to comment.