Allow up to 63-character-long TLDs in email addresses

This commit is contained in:
Nick Winter 2015-12-04 12:06:42 -08:00
parent c36bed8103
commit 6d6f6138b1
3 changed files with 5 additions and 5 deletions

View file

@ -89,7 +89,7 @@ module.exports = class SubscriptionView extends RootView
onClickRecipientsSubscribe: (e) ->
emails = @$el.find('.recipient-emails').val().split('\n')
valid = @emailValidator.validateEmails(emails, =>@render?())
@recipientSubs.startSubscribe(emails) if valid
@recipientSubs.startSubscribe(emails) if valid
onClickRecipientUnsubscribe: (e) ->
$(e.target).addClass('hide')
@ -108,8 +108,8 @@ class EmailValidator
validateEmails: (emails, render) ->
@lastEmails = emails.join('\n')
#taken from http://www.regular-expressions.info/email.html
emailRegex = /[A-z0-9._%+-]+@[A-z0-9.-]+\.[A-z]{2,4}/
#taken from http://www.regular-expressions.info/email.html
emailRegex = /[A-z0-9._%+-]+@[A-z0-9.-]+\.[A-z]{2,63}/
@validEmails = (email for email in emails when emailRegex.test(email.trim().toLowerCase()))
return @emailsInvalid(render) if @validEmails.length < emails.length
return @emailsValid(render)

View file

@ -79,7 +79,7 @@ module.exports = class AuthModal extends ModalView
emailCheck: ->
email = $('#email', @$el).val()
filter = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i # https://news.ycombinator.com/item?id=5763990
filter = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,63}$/i # https://news.ycombinator.com/item?id=5763990
unless filter.test(email)
forms.setErrorToProperty @$el, 'email', 'Please enter a valid email address', true
return false

View file

@ -37,7 +37,7 @@ module.exports = class StudentSignUpModal extends ModalView
emailCheck: ->
email = @$('#email').val()
filter = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i # https://news.ycombinator.com/item?id=5763990
filter = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,63}$/i # https://news.ycombinator.com/item?id=5763990
unless filter.test(email)
@$('#errors-alert').text($.i18n.t('share_progress_modal.email_invalid')).removeClass('hide')
return false