Skip to content

Message with a null byte in the decoded body can't be archived.

A message was posted to a list with

Content-Type: image/png;
	x-unix-mode=0644;
	name="Screen Shot 2019-12-11 at 4.02.58 pm.png"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
	filename="Screen Shot 2019-12-11 at 4.02.58 pm.png"

I.e., there was no text in the body, just the base64 encoded .png file. The first several bytes of the base64 decoded message body were b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x08x\x00\x00' which is fairly normal for a .png.

The attempt to post the message to hyperkitty returned a result with

>>> result.status_code
200
>>> result.text
'{"error": "A string literal cannot contain NUL (0x00) characters."}'

This in turn causes

Dec 11 07:37:49 2019 (23111) Exception in the HyperKitty archiver: 'url'
Dec 11 07:37:49 2019 (23111) Traceback (most recent call last):
  File "/opt/mailman/mm/venv/lib/python3.6/site-packages/mailman_hyperkitty-1.2.
0-py3.6.egg/mailman_hyperkitty/__init__.py", line 152, in _archive_message
    url = self._send_message(mlist, msg)
  File "/opt/mailman/mm/venv/lib/python3.6/site-packages/mailman_hyperkitty-1.2.
0-py3.6.egg/mailman_hyperkitty/__init__.py", line 215, in _send_message
    archived_url = result["url"]
KeyError: 'url'

in mailman_hyperkitty which requeues the message and keeps retrying it indefinitely.

At a minimum, hyperkitty should not return a 200 in this case which would at least result in a more meaningful log message.