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


Commits:
14af7e16 by Mark Sapiro at 2020-03-21T17:47:18-07:00
Don't import banned addresses.

- - - - -
a2a8d298 by Mark Sapiro at 2020-03-22T02:02:51+00:00
Merge branch 'fix_688' into 'master'

Don't import banned addresses.

Closes #688

See merge request mailman/mailman!604
- - - - -


3 changed files:

- src/mailman/docs/NEWS.rst
- src/mailman/utilities/importer.py
- src/mailman/utilities/tests/test_import.py


Changes:

=====================================
src/mailman/docs/NEWS.rst
=====================================
@@ -50,6 +50,7 @@ Bugs
   library which causes Templates loading to fail. (Closes #691)
 * Fix a bug due to incompatible API of a new version of ``zope.intefaces``.
   (See !606)
+* Import21 no longer tries to import banned addresses.  (Closes #688)
 
 REST
 ----


=====================================
src/mailman/utilities/importer.py
=====================================
@@ -587,11 +587,16 @@ def _import_roster(mlist, config_dict, members, role, 
action=None):
     validator = getUtility(IEmailValidator)
     roster = mlist.get_roster(role)
     skipped = []
+    banned = []
     action_arg = action
     for email in members:
         # For owners and members, the emails can have a mixed case, so
         # lowercase them all.
         email = bytes_to_str(email).lower()
+        # Ignore any banned addresses for all rosters.
+        if IBanManager(mlist).is_banned(email):
+            banned.append((email, role))
+            continue
         if roster.get_member(email) is not None:
             skipped.append((email, role))
             continue
@@ -694,3 +699,6 @@ def _import_roster(mlist, config_dict, members, role, 
action=None):
     for email, role in skipped:
         print('{} is already imported with role {}'.format(email, role),
               file=sys.stderr)
+    for email, role in banned:
+        print('{} is banned and not imported with role {}'.format(email, role),
+              file=sys.stderr)


=====================================
src/mailman/utilities/tests/test_import.py
=====================================
@@ -1176,6 +1176,15 @@ class TestRosterImport(unittest.TestCase):
         member = self._mlist.nonmembers.get_member('ho...@example.com')
         self.assertEqual(member.moderation_action, Action.hold)
 
+    def test_no_import_banned_address(self):
+        # Banned addresses should not be imported with any role.
+        self._pckdict['ban_list'] = [b'^.*example.com']
+        import_config_pck(self._mlist, self._pckdict)
+        self.assertEqual([], list(self._mlist.owners.addresses))
+        self.assertEqual([], list(self._mlist.moderators.addresses))
+        self.assertEqual([], list(self._mlist.members.addresses))
+        self.assertEqual([], list(self._mlist.nonmembers.addresses))
+
 
 class TestRosterVisibilityImport(unittest.TestCase):
     """Test that member_roster_visibility is imported correctly.



View it on GitLab: 
https://gitlab.com/mailman/mailman/-/compare/a3f4232a750402a5344ddb359e81a848b1177dbb...a2a8d298030b69c6d4e168669c1f2fbfe009c4f4

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


_______________________________________________
Mailman-checkins mailing list
Mailman-checkins@python.org
Unsubscribe: 
https://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org

Reply via email to