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


Commits:
d14847d0 by Mark Sapiro at 2022-02-17T14:48:31-08:00
Fix setting empty in list_of_emails_or_regexp_validator.

- - - - -
69785aaa by Mark Sapiro at 2022-02-17T23:14:54+00:00
Merge branch 'val' into 'master'

Fix setting empty in list_of_emails_or_regexp_validator.

See merge request mailman/mailman!963
- - - - -


2 changed files:

- src/mailman/rest/tests/test_validator.py
- src/mailman/rest/validator.py


Changes:

=====================================
src/mailman/rest/tests/test_validator.py
=====================================
@@ -52,6 +52,10 @@ class TestValidators(unittest.TestCase):
         # This validator should return an empty list for an empty string input.
         self.assertEqual(list_of_strings_validator(''), [])
 
+    def test_list_of_emails_or_regexp_validator_empty_list(self):
+        # This validator should return an empty list for an empty string input.
+        self.assertEqual(list_of_emails_or_regexp_validator(''), [])
+
     def test_integer_ge_zero_validator_invalid(self):
         self.assertRaises(ValueError, integer_ge_zero_validator, 'foo')
         self.assertRaises(ValueError, integer_ge_zero_validator, '-1')


=====================================
src/mailman/rest/validator.py
=====================================
@@ -132,12 +132,12 @@ def list_of_emails_validator(values):
 
 @public
 def list_of_emails_or_regexp_validator(values):
+    if values == '':
+        return []
     if not isinstance(values, (list, tuple)):
         values = [values]
     for value in values:
-        # Allow an empty value to clear the list.
-        if value:
-            email_or_regexp_validator(value)
+        email_or_regexp_validator(value)
     return values
 
 



View it on GitLab: 
https://gitlab.com/mailman/mailman/-/compare/a7113b5da5a1f8574dcb3bb4c2ea37ea88fec1ca...69785aaaf127a60415707aa7552d3e1c433034f9

-- 
View it on GitLab: 
https://gitlab.com/mailman/mailman/-/compare/a7113b5da5a1f8574dcb3bb4c2ea37ea88fec1ca...69785aaaf127a60415707aa7552d3e1c433034f9
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