It was only 3 commits necessary to fix this, but one of them needs further adjustment.
The upstream commits in question are: 59d8b47c432e43ce463cbb4a7aec649415d08702 e4d9e5202158f9b32bb985167d7dedd9e9edc263 05d608645cfa47f7150585663e9f2d6aa5688db2 But e4d9e5202158f9b32bb985167d7dedd9e9edc263 then runs into an extra problem where the Debian INN2 doesn't like header wrapping when a post is being made in READER mode. This might itself be an INN2 bug. RFC 3977 section A.1 does say that header wrapping should work over NNTP, but perhaps READER mode counts as nn*r*p instead and follows different rules? So I've instead ended up using a tweaked patch that forces the max_line_length to 'None' for no wrapping. I've attached the three extra patch files that I'm now using. -- - Athanasius = Athanasius(at)miggy.org / https://miggy.org/ GPG/PGP Key: https://miggy.org/gpg-key "And it's me who is my enemy. Me who beats me up. Me who makes the monsters. Me who strips my confidence." Paula Cole - ME
commit 59d8b47c432e43ce463cbb4a7aec649415d08702 Author: Mark Sapiro <m...@msapiro.net> Date: Sun Jun 23 01:52:23 2019 +0000 Removed the last remnants of the mailing list attribute nntp_host. diff --git a/src/mailman/core/tests/test_pipelines.py b/src/mailman/core/tests/test_pipelines.py index 7c87c4877..7ce778134 100644 --- a/src/mailman/core/tests/test_pipelines.py +++ b/src/mailman/core/tests/test_pipelines.py @@ -180,7 +180,6 @@ testing # Set up NNTP. self._mlist.gateway_to_news = True self._mlist.linked_newsgroup = 'testing' - self._mlist.nntp_host = 'news.example.com' # Process the email. process(self._mlist, self._msg, {}, pipeline_name='default-posting-pipeline') diff --git a/src/mailman/docs/NEWS.rst b/src/mailman/docs/NEWS.rst index ba8d7cdf9..bace916c7 100644 --- a/src/mailman/docs/NEWS.rst +++ b/src/mailman/docs/NEWS.rst @@ -18,6 +18,12 @@ ===== (2019-02-22) +Debian Cherry-Pick +------------------ + +* The last remnants of the mailing list attribute ``nntp_host`` have been + removed. (Closes #611) + Command line ------------ * The ``mailman import21`` command properly converts all acceptable_aliases diff --git a/src/mailman/handlers/docs/nntp.rst b/src/mailman/handlers/docs/nntp.rst index 72bcb35f0..233bbd255 100644 --- a/src/mailman/handlers/docs/nntp.rst +++ b/src/mailman/handlers/docs/nntp.rst @@ -44,12 +44,11 @@ Neither are digests ever gated to the newsgroup. [] However, other posted messages get gated to the newsgroup via the nntp queue. -The list owner can set the linked newsgroup and the nntp host that its -messages are gated to. +The list owner can set the linked newsgroup. The nntp host that messages are +gated to is a global configuration. :: >>> mlist.linked_newsgroup = 'comp.lang.thing' - >>> mlist.nntp_host = 'news.example.com' >>> handler.process(mlist, msg, {}) >>> messages = get_queue_messages('nntp') >>> len(messages) diff --git a/src/mailman/handlers/to_usenet.py b/src/mailman/handlers/to_usenet.py index 4e66b8e99..3dbf91bf1 100644 --- a/src/mailman/handlers/to_usenet.py +++ b/src/mailman/handlers/to_usenet.py @@ -50,8 +50,6 @@ class ToUsenet: error = [] if not mlist.linked_newsgroup: error.append('no newsgroup') - if not mlist.nntp_host: - error.append('no NNTP host') if error: log.error('NNTP gateway improperly configured: %s', COMMASPACE.join(error)) diff --git a/src/mailman/styles/base.py b/src/mailman/styles/base.py index 92168ed97..e95423484 100644 --- a/src/mailman/styles/base.py +++ b/src/mailman/styles/base.py @@ -92,7 +92,6 @@ class BasicOperation: mlist.dmarc_moderation_notice = '' mlist.dmarc_wrapped_message_text = '' # NNTP gateway - mlist.nntp_host = '' mlist.linked_newsgroup = '' mlist.gateway_to_news = False mlist.gateway_to_mail = False
commit e4d9e5202158f9b32bb985167d7dedd9e9edc263 Author: Mark Sapiro <m...@msapiro.net> Date: Thu Jun 27 15:52:58 2019 +0000 Fixed nntp runner to use BytesIO rather than StringIO. diff --git a/src/mailman/docs/NEWS.rst b/src/mailman/docs/NEWS.rst index 33920ec8d..2f6f041a4 100644 --- a/src/mailman/docs/NEWS.rst +++ b/src/mailman/docs/NEWS.rst @@ -23,6 +23,8 @@ * The last remnants of the mailing list attribute ``nntp_host`` have been removed. (Closes #611) +* Fixed the nntp runner which was calling the ``nntplib.NNTP.post()`` method + with a string object instead of bytes. (Closes #613) Command line ------------ diff --git a/src/mailman/runners/nntp.py b/src/mailman/runners/nntp.py index 36ef2e3a1..580d22ff9 100644 --- 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, diff --git a/src/mailman/runners/tests/test_nntp.py b/src/mailman/runners/tests/test_nntp.py index 113a8da42..1c7d11f57 100644 --- a/src/mailman/runners/tests/test_nntp.py +++ b/src/mailman/runners/tests/test_nntp.py @@ -21,6 +21,7 @@ import socket import nntplib import unittest +from email import message_from_bytes from mailman.app.lifecycle import create_list from mailman.config import config from mailman.interfaces.nntp import NewsgroupModeration @@ -274,7 +275,7 @@ Testing self.assertEqual(len(args[0]), 1) # No keyword arguments. self.assertEqual(len(args[1]), 0) - msg = mfs(args[0][0].read()) + msg = message_from_bytes(args[0][0].read()) self.assertEqual(msg['subject'], 'A newsgroup posting') @mock.patch('nntplib.NNTP') diff --git a/src/mailman/testing/helpers.py b/src/mailman/testing/helpers.py index 003e01e4a..82461b5f4 100644 --- a/src/mailman/testing/helpers.py +++ b/src/mailman/testing/helpers.py @@ -30,7 +30,7 @@ import datetime import threading from contextlib import contextmanager, suppress -from email import message_from_string +from email import message_from_bytes, message_from_string from lazr.config import as_timedelta from mailman.bin.master import Loop as Master from mailman.config import config @@ -250,7 +250,7 @@ def get_nntp_server(cleanups): class NNTPProxy: # noqa: E306 def get_message(self): args = nntpd.post.call_args - return specialized_message_from_string(args[0][0].read()) + return message_from_bytes(args[0][0].read()) return NNTPProxy()
commit 05d608645cfa47f7150585663e9f2d6aa5688db2 Author: Mark Sapiro <m...@msapiro.net> Date: Wed Aug 21 18:32:43 2019 +0000 Properly capitalize new Subject: header. diff --git a/src/mailman/runners/nntp.py b/src/mailman/runners/nntp.py index 8b5c65ab5..334a2be06 100644 --- a/src/mailman/runners/nntp.py +++ b/src/mailman/runners/nntp.py @@ -110,7 +110,7 @@ def prepare_message(mlist, msg, msgdata): msgdata.get('original_subject')) if not mlist.nntp_prefix_subject_too and stripped_subject is not None: del msg['subject'] - msg['subject'] = stripped_subject + msg['Subject'] = stripped_subject # Add the appropriate Newsgroups header. Multiple Newsgroups headers are # generally not allowed so we're not testing for them. header = msg.get('newsgroups')