psycopg (v3) strictly rejects NUL bytes (0x00) in PostgreSQL text
fields, unlike psycopg2 which handled them silently. Malformed emails
(such as the codec-null.mbox fuzz fixture in our test suite) contain NUL
bytes in headers and body content, causing DataError on insert.
Strip NUL bytes from all text fields before they reach the database.
This is safe for all fields:
* Headers are restricted to printable ASCII by RFC 5322 meaning NUL
bytes there always indicate corruption
* Email body / commit message content is plain text so NUL bytes are
equally invalid here
* Unified diffs should also never contain NUL bytes. Git uses their
presence as the heuristic to classify a file as binary, at which point
it either emits 'Binary files ... differ' or, with --binary, a
base85-encoded binary patch, both of which are entirely printable
ASCII. A legitimate patch produced by git format-patch will therefore
never carry NUL bytes in the diff text itself.
Signed-off-by: Stephen Finucane <stephen@that.guru>