Bhavesh Goyal has proposed merging
lp:~bhavesh-goyal093/postorius/fixed-invalid-email-acceptance into lp:postorius.
Requested reviews:
Mailman Coders (mailman-coders)
For more details, see:
https://code.launchpad.net/~bhavesh-goyal093/postorius/fixed-invalid-email-acceptance/+merge/255447
Earlier The Mass Subscription also allowed some invalid email addresses such as
[email protected], [email protected] to get subscribed to a mailing list, which
could have led to Server Errors in long run while sending mass mails.
Now The Emails are successfully validated using Django EmailValidators and all
the invalid emails including the ones ignored earlier are now rejected by
throwing a Email Validation Error.
--
Your team Mailman Coders is requested to review the proposed merge of
lp:~bhavesh-goyal093/postorius/fixed-invalid-email-acceptance into lp:postorius.
=== modified file 'src/postorius/views/list.py'
--- src/postorius/views/list.py 2015-02-09 14:35:44 +0000
+++ src/postorius/views/list.py 2015-04-07 23:12:00 +0000
@@ -24,6 +24,8 @@
from django.core.urlresolvers import reverse
from django.shortcuts import render_to_response, redirect
from django.template import RequestContext
+from django.core.validators import validate_email
+from django.core.exceptions import ValidationError
from django.utils.decorators import method_decorator
from django.utils.translation import gettext as _
from urllib2 import HTTPError
@@ -249,25 +251,22 @@
else:
emails = request.POST["emails"].splitlines()
for email in emails:
- parts = email.split('@')
- if len(parts) != 2 or '.' not in parts[1]:
+ try:
+ validate_email(email)
+ self.mailing_list.subscribe(address=email)
+ messages.success(request,
+ 'The address %s has been subscribed to %s.' %
+ (email, self.mailing_list.fqdn_listname))
+ except MailmanApiError:
+ return utils.render_api_error(request)
+ except HTTPError, e:
+ messages.error(request, e)
+ except ValidationError:
messages.error(request,
'The email address %s is not valid.' %
email)
- else:
- try:
- self.mailing_list.subscribe(address=email)
- messages.success(
- request,
- 'The address %s has been subscribed to %s.' %
- (email, self.mailing_list.fqdn_listname))
- except MailmanApiError:
- return utils.render_api_error(request)
- except HTTPError, e:
- messages.error(request, e)
return redirect('mass_subscribe', self.mailing_list.list_id)
-
def _get_choosable_domains(request):
try:
domains = Domain.objects.all()
_______________________________________________
Mailman-coders mailing list
[email protected]
https://mail.python.org/mailman/listinfo/mailman-coders