[PATCH] Fix missing SHOULD header bytes representation

Bug #1541343 reported by toxinu
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
dkimpy
Fix Released
Medium
Unassigned

Bug Description

This bug only occur with Python 3 (tested with 3.4).

`references` header field in DKIM.SHOULD is not represented as bytes.

Test that show bug:

```
def test_simple_signature(self):
    # A message verifies after being signed with SHOULD headers
    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=(b'from',) + dkim.DKIM.SHOULD)
     res = dkim.verify(sig + self.message, dnsfunc=self.dnsfunc)
     self.assertTrue(res)
```

======================================================================
ERROR: test_simple_signature (dkim.tests.test_dkim.TestSignAndVerify)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/glehee/Documents/Repositories/dkimpy/dkim/tests/test_dkim.py", line 87, in test_simple_signature
    include_headers=(b'from',) + dkim.DKIM.SHOULD)
  File "/home/glehee/Documents/Repositories/dkimpy/dkim/__init__.py", line 620, in sign
    return d.sign(selector, domain, privkey, identity=identity, canonicalize=canonicalize, include_headers=include_headers, length=length)
  File "/home/glehee/Documents/Repositories/dkimpy/dkim/__init__.py", line 471, in sign
    (b'h', b" : ".join(include_headers)),
TypeError: sequence item 20: expected a bytes-like object, str found

You can found this work on our github branch here:

https://github.com/oasiswork/dkimpy/commit/6a4dd61b86f8358d4632c17ea6636651387874c7

Revision history for this message
toxinu (toxinu) wrote :
description: updated
Revision history for this message
Scott Kitterman (kitterman) wrote :

The underlying issue was fixed in commit 134. Added the new test case based on your patch. Thanks. This will be in version 0.6.2.

Changed in dkimpy:
importance: Undecided → Medium
status: New → Fix Committed
Revision history for this message
Scott Kitterman (kitterman) wrote :

2017-05-30 Version 0.6.2
    - Fixed problem with header folding that caused the first line to be
      folded too long (Updated test test_add_body_length since l= tag is no
      longer at the beginning of a line)
    - Fixed python3.4 string interpolation issue
    - Fix some byte casting issues & typos
    - Add test case for verification when should headers are signed
    - Check and update references:
      * Replace RFC 4871 withRFC 6376
      * Replaace RFC 3447 with RFC 8017
      * Add mention of DCRUP working group addressing key length issues

Changed in dkimpy:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.