From 01541a3c36ab46ae45b3cf87109a0f194790f8e0 Mon Sep 17 00:00:00 2001 From: Stuart D Gathman Date: Thu, 6 Aug 2015 22:24:34 -0400 Subject: [PATCH] Fix and test case for case insensitive subdomain matching. --- dkim/__init__.py | 2 +- dkim/tests/test_dkim.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/dkim/__init__.py b/dkim/__init__.py index 8a6e330..eec9992 100644 --- a/dkim/__init__.py +++ b/dkim/__init__.py @@ -161,7 +161,7 @@ def validate_signature_fields(sig): # Nasty hack to support both str and bytes... check for both the # character and integer values. if b'i' in sig and ( - not sig[b'i'].endswith(sig[b'd']) or + not sig[b'i'].lower().endswith(sig[b'd'].lower()) or sig[b'i'][-len(sig[b'd'])-1] not in ('@', '.', 64, 46)): raise ValidationError( "i= domain is not a subdomain of d= (i=%s d=%s)" % diff --git a/dkim/tests/test_dkim.py b/dkim/tests/test_dkim.py index 30062d4..d721d78 100644 --- a/dkim/tests/test_dkim.py +++ b/dkim/tests/test_dkim.py @@ -232,6 +232,7 @@ b/mPfjC0QJTocVBq6Za/PlzfV+Py92VaCak19F4WrbVTK5Gg5tW220MCAwEAAQ== b'bh': b'n0HUwGCP28PkesXBPH82Kboy8LhNFWU9zUISIpAez7M=', b'c': b'simple/simple', b'd': b'kitterman.com', + b'i': b'scott@Kitterman.com', b'h': b'From:To:Subject:Date:Cc:MIME-Version:Content-Type:\n \t Content-Transfer-Encoding:Message-Id', b's': b'2007-00', b't': b'1299525798'}