NNTP Gateway fails due to default line wrapping
I'm running on Debian which doesn't yet have the fix the news post body being passed as string instead of bytes, but I've patched that and other relevant changes in from commits:
But then I run into:
nntplib.NNTPTemporaryError: 441 Invalid syntax encountered in headers (unexpected byte, no colon-space, or empty content line)
which is because the as_bytes() call is using an email module policy with the default line-wrap of 78 characters. Debian's INN2 does not like that line wrapping, it's just completely invalid. So, that code needs to modify the policy to not have a max_line_length:
# Flatten the message object, sticking it in a BytesIO object
fp = BytesIO(msg.as_bytes(policy=msg.policy.clone(max_line_length=0)))
conn = None
the patch I'm now applying is:
--- a/src/mailman/runners/nntp.py
+++ b/src/mailman/runners/nntp.py
@@ -23,7 +23,7 @@ import socket
import logging
import nntplib
-from io import StringIO
+from io import BytesIO
from mailman.config import config
from mailman.core.runner import Runner
from mailman.interfaces.nntp import NewsgroupModeration
@@ -66,8 +66,8 @@ class NNTPRunner(Runner):
# Make sure we have the most up-to-date state
if not msgdata.get('prepped'):
prepare_message(mlist, msg, msgdata)
- # Flatten the message object, sticking it in a StringIO object
- fp = StringIO(msg.as_string())
+ # Flatten the message object, sticking it in a BytesIO object
+ fp = BytesIO(msg.as_bytes(policy=msg.policy.clone(max_line_length=None)))
conn = None
try:
conn = nntplib.NNTP(host, port,