Really fix test case for bug#737311

This commit is contained in:
Stuart D. Gathman
2011-06-17 14:28:07 -04:00
parent a203b29874
commit 2458f3824c
2 changed files with 5 additions and 4 deletions
+4 -3
View File
@@ -99,7 +99,8 @@ def select_headers(headers, include_headers):
""" """
sign_headers = [] sign_headers = []
lastindex = {} 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)) i = lastindex.get(h, len(headers))
while i > 0: while i > 0:
i -= 1 i -= 1
@@ -374,12 +375,12 @@ class DKIM(object):
except (TypeError,UnparsableKeyError) as e: except (TypeError,UnparsableKeyError) as e:
raise KeyFormatError("could not parse public key (%s): %s" % (pub[b'p'],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 # address bug#644046 by including any additional From header
# fields when verifying. Since there should be only one From header, # fields when verifying. Since there should be only one From header,
# this shouldn't break any legitimate messages. This could be # this shouldn't break any legitimate messages. This could be
# generalized to check for extras of other singleton headers. # 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') include_headers.append('from')
h = hasher() h = hasher()
hash_headers(h, canon_policy, headers, include_headers, sigheaders, sig) hash_headers(h, canon_policy, headers, include_headers, sigheaders, sig)
+1 -1
View File
@@ -139,7 +139,7 @@ b/mPfjC0QJTocVBq6Za/PlzfV+Py92VaCak19F4WrbVTK5Gg5tW220MCAwEAAQ=="""
sig = dkim.sign( sig = dkim.sign(
message, b"test", b"example.com", self.key, message, b"test", b"example.com", self.key,
canonicalize=(header_algo, body_algo)) 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) self.assertTrue(res)
def test_multiple_from_fails(self): def test_multiple_from_fails(self):