From e0e11eaab0be870ce5514680e7ec9e9a3fee78d0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=D0=94=D0=B8=D0=BB=D1=8F=D0=BD=20=D0=9F=D0=B0=D0=BB=D0=B0?= =?utf8?q?=D1=83=D0=B7=D0=BE=D0=B2?= Date: Wed, 4 Jan 2023 13:17:47 +0000 Subject: [PATCH] fix: Show the RFC2047-decoded name of the user in confirm_token view --- src/postorius/doc/news.rst | 4 ++++ src/postorius/tests/mailman_api_tests/test_list_moderation.py | 7 +++++-- src/postorius/views/list.py | 7 +++++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/postorius/doc/news.rst b/src/postorius/doc/news.rst index 6a3c93cd..2f7b3b65 100644 --- a/src/postorius/doc/news.rst +++ b/src/postorius/doc/news.rst @@ -22,6 +22,10 @@ along with Postorius. If not, see . 1.3.9 ===== +UI +-- + +* Use RFC 2047 decoded user names in the confirm_token view. (Fixes #564) .. _NEWS-1.3.8: diff --git a/src/postorius/tests/mailman_api_tests/test_list_moderation.py b/src/postorius/tests/mailman_api_tests/test_list_moderation.py index 348710af..e24bb835 100644 --- a/src/postorius/tests/mailman_api_tests/test_list_moderation.py +++ b/src/postorius/tests/mailman_api_tests/test_list_moderation.py @@ -269,14 +269,17 @@ class TestConfirmToken(ViewTestCase): def test_confirm_token(self): # Test that we can first get a token page to confirm. - token = self.mlist.subscribe('aperson@example.com', 'Anne Person') + token = self.mlist.subscribe('aperson@example.com', 'Anne Петрова') self.assertIsNotNone(token.get('token')) resp = self.client.get( reverse('confirm_token', args=(self.mlist.list_id,)) + '?token={}'.format(token.get('token')) ) self.assertEqual(resp.status_code, 200) - self.assertTrue(b'Confirm subscription of Anne Person' in resp.content) + self.assertTrue( + 'Confirm subscription of Anne Петрова' + in resp.content.decode('utf-8') + ) self.assertTrue(token.get('token') in resp.content.decode('utf-8')) # Now, let's confirm the token. with self.assertRaises(ValueError): diff --git a/src/postorius/views/list.py b/src/postorius/views/list.py index 85e0d78d..2aad2206 100644 --- a/src/postorius/views/list.py +++ b/src/postorius/views/list.py @@ -1629,8 +1629,11 @@ def confirm_token(request, list_id): form = TokenConfirmForm(initial=dict(token=token)) # Show the display_name if it is not None or "". if pending_req.get('display_name'): - addr = email.utils.formataddr( - (pending_req.get('display_name'), pending_req.get('email')) + addr = ( + pending_req.get('display_name') + + ' <' + + pending_req.get('email') + + '>' ) else: addr = pending_req.get('email') -- 2.11.4.GIT