cfinput not accepting .education domain names

106 views Asked by At

For the first time ever I had two users come into my app with a .education top level domain. Their email address looked like this: [email protected]. I'm using the cfinput validate attribute on the form they are filling out as follows:

<cfinput type="text" name="email" required="yes" message="Please enter a valid email address." validate="email">

When the users submits the form they are getting my error message. The form has been working successfully for years on all the other email addresses entered. Are there any tricks to make it take this top level domain? TIA

2

There are 2 answers

0
Jason Holden On

I agree with the other answers about limiting your use of cfinput, but as a quick fix you should be able to use the cfinput PATTERN attribute (https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-tags/tags-i/cfinput.html):

<cfinput type="text" name="email" required="yes" message="Please enter a valid email address." validate="regex" pattern="(?:[a-z0-9!##$%&'+/=?^_{|}~-]+(?:\.[a-z0-9!##$%&'*+/=?^_{|}~-]+)|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\[\x01-\x09\x0b\x0c\x0e-\x7f])")@(?:(?:a-z0-9?.)+a-z0-9?|[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-][a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\[\x01-\x09\x0b\x0c\x0e-\x7f])+)])">

The PATTERN attribute can be changed to any regular expression. The one provided is RFC 5322 compliant.

EDIT: Changed pattern to Java based RegEx and escaped #'s

2
Adrian J. Moreno On

Avoid all of the ColdFusion UI tags. They will only cause pain.

Each version of ColdFusion updates the built-in email validation to handle the new top-level domains (TLD) of the time. There are nearly 1600 active TLDs at the moment.

  • Javascript validation isn't going to cut it.
  • Regular expressions won't either.
  • You will need to validate on the server if you aren't already.

Better you remove that validation rule for a start and send an email to verify the email account exists before activating the user on your app.