Mark Sapiro pushed to branch master at GNU Mailman / Mailman Core
Commits:
ce7ac672 by Дилян Палаузов at 2022-03-31T18:45:24+00:00
Decode From: and Subject: in email command Replies
- - - - -
b02d188f by Mark Sapiro at 2022-03-31T18:45:24+00:00
Merge branch 'decode_subject_in_email_command_reply' into
'master'
Decode From: and Subject: in email command Replies
See merge request mailman/mailman!1003
- - - - -
3 changed files:
- src/mailman/docs/NEWS.rst
- src/mailman/runners/command.py
- src/mailman/runners/tests/test_confirm.py
Changes:
=====================================
src/mailman/docs/NEWS.rst
=====================================
@@ -57,6 +57,8 @@ Bugs fixed
* The subject of Welcome and Goodbye messages is now translated (Closes #1000)
* Emails to a list's ``-join``, ``-leave`` or ``-confirm`` address that result
in some errors will now produce a response. (Closes #991)
+* RFC2047 encoded Subject: and From: headers reported in email command replies
+ are now decoded. (Closes #999)
REST
====
=====================================
src/mailman/runners/command.py
=====================================
@@ -186,9 +186,11 @@ class CommandRunner(Runner):
# Include just a few key pieces of information from the original: the
# sender, date, and message id.
print(_('- Original message details:'), file=results)
- subject = msg.get('subject', 'n/a') # noqa: F841
+ subject = str(make_header(decode_header( # noqa: F841
+ msg.get('subject', 'n/a'))))
date = msg.get('date', 'n/a') # noqa: F841
- from_ = msg.get('from', 'n/a') # noqa: F841
+ from_ = str(make_header(decode_header( # noqa: F841
+ msg.get('from', 'n/a'))))
print(_(' From: ${from_}'), file=results)
print(_(' Subject: ${subject}'), file=results)
print(_(' Date: ${date}'), file=results)
=====================================
src/mailman/runners/tests/test_confirm.py
=====================================
@@ -385,3 +385,26 @@ To: [email protected]
self._runner.run()
# This should send out an error email.
get_queue_messages('virgin', expected_count=1)
+
+ def test_confirm_with_non_ascii_from_and_subject(self):
+ # this test shall return in the body the RFC2047-decoded
+ # From:display-part and Subject:
+ get_queue_messages('virgin')
+ msg = mfs("""\
+From: =?utf-8?Q?=D0=90=D0=BD=D0=B0?= <[email protected]>
+Subject: =?utf-8?Q?=D0=9A=D1=8A=D1=89=D0=B0?=
+
+bad-command
+""")
+ self._commandq.enqueue(msg, dict(listid='test.example.com',
+ subaddress='confirm'))
+ self._runner.run()
+ # This should send out one email that confirms that token was accepted.
+ items = get_queue_messages('virgin', expected_count=1)
+ msg_result = items[0].msg
+ payload = msg_result.get_payload()
+ encoding = msg_result.get('Content-Transfer-Encoding')
+ if encoding and encoding.lower() == 'base64':
+ payload = base64.b64decode(payload).decode('utf-8')
+ self.assertIn('Ана <[email protected]>', payload)
+ self.assertIn('Къща', payload)
View it on GitLab:
https://gitlab.com/mailman/mailman/-/compare/4fa4f87f01561d8ef0b25094a5831980d72128da...b02d188fca31c5c0ddb9d679fa8dea9e6077c076
--
View it on GitLab:
https://gitlab.com/mailman/mailman/-/compare/4fa4f87f01561d8ef0b25094a5831980d72128da...b02d188fca31c5c0ddb9d679fa8dea9e6077c076
You're receiving this email because of your account on gitlab.com.
_______________________________________________
Mailman-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/mailman-checkins.python.org/
Member address: [email protected]