|
|
|
@ -31,6 +31,7 @@ from io import BytesIO |
|
|
|
|
import logging |
|
|
|
|
import os |
|
|
|
|
import tempfile |
|
|
|
|
import time |
|
|
|
|
|
|
|
|
|
from flufl.lock import Lock |
|
|
|
|
from mailman.config import config |
|
|
|
@ -90,6 +91,15 @@ class Pipermail: |
|
|
|
|
:type mlist: mailman.interfaces.mailinglist.IMailingList |
|
|
|
|
:type message: mailman.email.message.Message |
|
|
|
|
""" |
|
|
|
|
|
|
|
|
|
# Workaround for a bug in Mailman which sets unixfrom to an email |
|
|
|
|
# address instead of an mbox header |
|
|
|
|
# https://gitlab.com/mailman/mailman/-/blob/master/src/mailman/runners/lmtp.py#L139 |
|
|
|
|
old_unixfrom = msg.get_unixfrom() |
|
|
|
|
if old_unixfrom is not None and not old_unixfrom.startswith('From '): |
|
|
|
|
# Adapted from https://github.com/python/cpython/blob/3.9/Lib/email/generator.py |
|
|
|
|
msg.set_unixfrom('From ' + old_unixfrom + ' ' + time.ctime(time.time())) |
|
|
|
|
|
|
|
|
|
# Mangle the 'From ' lines and add the Unix envelope header. |
|
|
|
|
fp = BytesIO() |
|
|
|
|
g = BytesGenerator(fp, mangle_from_=True) |
|
|
|
@ -135,5 +145,6 @@ class Pipermail: |
|
|
|
|
finally: |
|
|
|
|
lock.unlock(unconditionally=True) |
|
|
|
|
os.unlink(tempfile_name) |
|
|
|
|
msg.set_unixfrom(old_unixfrom) |
|
|
|
|
|
|
|
|
|
return None |
|
|
|
|