From 88bbd1fe351d9db2fdb8bbc23915bbcbc77d0eda Mon Sep 17 00:00:00 2001 From: bwarsaw Date: Tue, 29 Dec 1998 20:52:49 +0000 Subject: ChangeOptions(): Rework the test for empty or whitespace-only blank line in mass subscribe dialog. The old way didn't really work. --- Mailman/Cgi/admin.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/Mailman/Cgi/admin.py b/Mailman/Cgi/admin.py index e30f2e0cb..ef4b2f756 100644 --- a/Mailman/Cgi/admin.py +++ b/Mailman/Cgi/admin.py @@ -741,28 +741,38 @@ def ChangeOptions(lst, category, cgi_info, document): name_text = cgi_info['subscribees'].value name_text = string.replace(name_text, '\r', '') names = string.split(name_text, '\n') - if '' in names: - names.remove('') subscribe_success = [] subscribe_errors = [] send_welcome_msg = string.atoi(cgi_info["send_welcome_msg_to_this_batch"].value) - for new_name in map(string.strip,names): + for new_name in map(string.strip, names): digest = 0 if not lst.digestable: digest = 0 if not lst.nondigestable: digest = 1 try: - lst.ApprovedAddMember(new_name, (Utils.GetRandomSeed() + - Utils.GetRandomSeed()), digest, send_welcome_msg) + # catches blank lines or whitespace-only lines in mass + # subscribe dialog + if not new_name: + # TBD: we raise the exception here instead of just + # appending to subscribe_errors and doing a continue, + # because as of Python 1.5.2, this is not supported syntax + # (a continue inside the try inside a loop). + new_name = '<blank line>' + raise Errors.MMBadEmailError + lst.ApprovedAddMember( + new_name, + Utils.GetRandomSeed() + Utils.GetRandomSeed(), + digest, send_welcome_msg) subscribe_success.append(new_name) except Errors.MMAlreadyAMember: subscribe_errors.append((new_name, 'Already a member')) - except Errors.MMBadEmailError: - subscribe_errors.append((new_name, "Bad/Invalid email address")) + subscribe_errors.append( + (new_name, "Bad/Invalid email address")) except Errors.MMHostileAddress: - subscribe_errors.append((new_name, "Hostile Address (illegal characters)")) + subscribe_errors.append( + (new_name, "Hostile Address (illegal characters)")) if subscribe_success: document.AddItem(Header(5, "Successfully Subscribed:")) document.AddItem(apply(UnorderedList, tuple((subscribe_success)))) -- cgit v1.2.3-70-g09d2