Don't error out in Python 3 if include headers is string (LP: #1776775)
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
- Add testing extras option to setup.py (Daniel Hahler)
|
- Add testing extras option to setup.py (Daniel Hahler)
|
||||||
- Fix deprecation warnings in test asserts (Daniel Hahler)
|
- Fix deprecation warnings in test asserts (Daniel Hahler)
|
||||||
- Correctly limit try/except for imports to import errors (Daniel Hahler)
|
- Correctly limit try/except for imports to import errors (Daniel Hahler)
|
||||||
|
- Don't error out in Python 3 if include headers is string (LP: #1776775)
|
||||||
|
|
||||||
2018-05-18 Version 0.8.0
|
2018-05-18 Version 0.8.0
|
||||||
- Change from distutils to setuptools with entry points because it's the
|
- Change from distutils to setuptools with entry points because it's the
|
||||||
|
|||||||
@@ -724,6 +724,12 @@ class DKIM(DomainSigner):
|
|||||||
|
|
||||||
if include_headers is None:
|
if include_headers is None:
|
||||||
include_headers = self.default_sign_headers()
|
include_headers = self.default_sign_headers()
|
||||||
|
try:
|
||||||
|
include_headers = [bytes(x, 'utf-8') for x in include_headers]
|
||||||
|
except TypeError:
|
||||||
|
# TypeError means it's already bytes and we're good or we're in
|
||||||
|
# Python 2 and we don't care. See LP: #1776775.
|
||||||
|
pass
|
||||||
|
|
||||||
include_headers = tuple([x.lower() for x in include_headers])
|
include_headers = tuple([x.lower() for x in include_headers])
|
||||||
# record what verify should extract
|
# record what verify should extract
|
||||||
|
|||||||
@@ -244,6 +244,17 @@ p=11qYAYKxCrfVS/7TyWQHOg7hcvPapiMlrwIaaPcHURo="""
|
|||||||
res = dkim.verify(sig + self.message, dnsfunc=self.dnsfunc)
|
res = dkim.verify(sig + self.message, dnsfunc=self.dnsfunc)
|
||||||
self.assertTrue(res)
|
self.assertTrue(res)
|
||||||
|
|
||||||
|
def test_string_include(self):
|
||||||
|
# A message can be signed when the include_headers is string
|
||||||
|
for header_algo in (b"simple", b"relaxed"):
|
||||||
|
for body_algo in (b"simple", b"relaxed"):
|
||||||
|
sig = dkim.sign(
|
||||||
|
self.message, b"test", b"example.com", self.key,
|
||||||
|
canonicalize=(header_algo, body_algo),
|
||||||
|
include_headers=('from',) )
|
||||||
|
res = dkim.verify(sig + self.message, dnsfunc=self.dnsfunc)
|
||||||
|
self.assertTrue(res)
|
||||||
|
|
||||||
def test_add_body_length(self):
|
def test_add_body_length(self):
|
||||||
sig = dkim.sign(
|
sig = dkim.sign(
|
||||||
self.message, b"test", b"example.com", self.key, length=True)
|
self.message, b"test", b"example.com", self.key, length=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user