From 2458f3824cc75031a05e32460aea218ea922bad8 Mon Sep 17 00:00:00 2001 From: "Stuart D. Gathman" Date: Fri, 17 Jun 2011 14:28:07 -0400 Subject: [PATCH] Really fix test case for bug#737311 --- dkim/__init__.py | 7 ++++--- dkim/tests/test_dkim.py | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/dkim/__init__.py b/dkim/__init__.py index 64e2d98..05df719 100644 --- a/dkim/__init__.py +++ b/dkim/__init__.py @@ -99,7 +99,8 @@ def select_headers(headers, include_headers): """ sign_headers = [] lastindex = {} - for h in [x.lower() for x in include_headers]: + for h in include_headers: + assert h == h.lower() i = lastindex.get(h, len(headers)) while i > 0: i -= 1 @@ -374,12 +375,12 @@ class DKIM(object): except (TypeError,UnparsableKeyError) as e: raise KeyFormatError("could not parse public key (%s): %s" % (pub[b'p'],e)) - include_headers = re.split(br"\s*:\s*", sig[b'h']) + include_headers = [x.lower() for x in re.split(br"\s*:\s*", sig[b'h'])] # address bug#644046 by including any additional From header # fields when verifying. Since there should be only one From header, # this shouldn't break any legitimate messages. This could be # generalized to check for extras of other singleton headers. - if 'from' in [x.lower() for x in include_headers]: + if 'from' in include_headers: include_headers.append('from') h = hasher() hash_headers(h, canon_policy, headers, include_headers, sigheaders, sig) diff --git a/dkim/tests/test_dkim.py b/dkim/tests/test_dkim.py index 89c267d..f676e18 100644 --- a/dkim/tests/test_dkim.py +++ b/dkim/tests/test_dkim.py @@ -139,7 +139,7 @@ b/mPfjC0QJTocVBq6Za/PlzfV+Py92VaCak19F4WrbVTK5Gg5tW220MCAwEAAQ==""" sig = dkim.sign( message, b"test", b"example.com", self.key, canonicalize=(header_algo, body_algo)) - res = dkim.verify(sig + self.message, dnsfunc=self.dnsfunc) + res = dkim.verify(sig + message, dnsfunc=self.dnsfunc) self.assertTrue(res) def test_multiple_from_fails(self):