Mark Sapiro pushed to branch master at GNU Mailman / Mailman Core


Commits:
b5630420 by Mark Sapiro at 2021-05-06T23:55:56+00:00
Handle RFC 2047 encoded command with non-ascii prefix.

- - - - -
b3786e04 by Mark Sapiro at 2021-05-06T23:56:08+00:00
Merge branch 'na' into 'master'

Handle RFC 2047 encoded command with non-ascii prefix.

Closes #858

See merge request mailman/mailman!851
- - - - -


4 changed files:

- setup.py
- src/mailman/docs/NEWS.rst
- src/mailman/runners/command.py
- src/mailman/runners/tests/test_confirm.py


Changes:

=====================================
setup.py
=====================================
@@ -111,7 +111,7 @@ case second 'm'.  Any other spelling is incorrect.""",
         },
     install_requires = [
         'aiosmtpd>=1.4.1',
-        'alembic',
+        'alembic<1.6.0',
         'atpublic',
         'authheaders>=0.9.2',
         'authres>=1.0.1',


=====================================
src/mailman/docs/NEWS.rst
=====================================
@@ -56,6 +56,8 @@ Bugs
   and #886)
 * The mailing list administrators roster ``get_member()`` method now returns
   the owner if the target is both an owner and moderator.  (Closes #888)
+* Command runner now handles RFC 2047 encoded command with non-ascii prefix.
+  (Closes #858)
 
 Command line
 ------------


=====================================
src/mailman/runners/command.py
=====================================
@@ -83,8 +83,8 @@ class CommandFinder:
         raw_subject = msg.get('subject', '')
         try:
             subject = str(make_header(decode_header(raw_subject)))
-            # Mail commands must be ASCII.
-            self.command_lines.append(subject.encode('us-ascii'))
+            # Mail commands must be ASCII, so strip non-ascii.
+            self.command_lines.append(subject.encode('us-ascii', 'ignore'))
         except (HeaderParseError, UnicodeError, LookupError):
             # The Subject header was unparseable or not ASCII.  If the raw
             # subject is a unicode object, convert it to ASCII ignoring all


=====================================
src/mailman/runners/tests/test_confirm.py
=====================================
@@ -109,6 +109,28 @@ To: test-conf...@example.com
         address = manager.get_address('a...@example.org')
         self.assertEqual(address.email, 'a...@example.org')
 
+    def test_confirm_with_non_ascii_prefix_and_encoded_command(self):
+        msg = mfs("""\
+From: a...@example.org
+To: test-conf...@example.com
+""")
+        conf = 'confirm {}'.format(self._token)
+        rfc2047_conf = base64.encodebytes(conf.encode()).strip().decode()
+        msg['Subject'] = '=?utf-8?b?5Zue5aSNOiA?= =?us-ascii?b?{}?='.format(
+            rfc2047_conf)
+        self._commandq.enqueue(msg, dict(listid='test.example.com'))
+        self._runner.run()
+        # Anne is now a confirmed member so her user record and email address
+        # should exist in the database.
+        manager = getUtility(IUserManager)
+        user = manager.get_user('a...@example.org')
+        address = list(user.addresses)[0]
+        self.assertEqual(address.email, 'a...@example.org')
+        self.assertEqual(address.verified_on,
+                         datetime(2005, 8, 1, 7, 49, 23))
+        address = manager.get_address('a...@example.org')
+        self.assertEqual(address.email, 'a...@example.org')
+
     def test_confirm_with_command_in_base64_encoded_body(self):
         # Clear out the virgin queue so that the test below only sees the
         # reply to the confirmation message.



View it on GitLab: 
https://gitlab.com/mailman/mailman/-/compare/732e97a3da9b6b3b27d152ea3458794f2c68f724...b3786e04e8861626e9f70574cbeb91b3b5c66b9b

-- 
View it on GitLab: 
https://gitlab.com/mailman/mailman/-/compare/732e97a3da9b6b3b27d152ea3458794f2c68f724...b3786e04e8861626e9f70574cbeb91b3b5c66b9b
You're receiving this email because of your account on gitlab.com.


_______________________________________________
Mailman-checkins mailing list -- mailman-checkins@python.org
To unsubscribe send an email to mailman-checkins-le...@python.org
https://mail.python.org/mailman3/lists/mailman-checkins.python.org/
Member address: arch...@jab.org

Reply via email to