isValid("email") fails on examples from wikipedia

Description

Wikipedia has a list of sample email addresses
https://en.wikipedia.org/wiki/Email_address#Local-part

https://trycf.com/gist/7b8590667278453962df9783ccfc5abb/lucee5?theme=monokai

Lucee returns wrong results,

  • with quoted strings / double dots,

  • when the local part (before the @) exceeds 64 characters

valid examples simple@example.com very.common@example.com disposable.style.email.with+symbol@example.com other.email-with-hyphen@example.com fully-qualified-domain@example.com user.name+tag+sorting@example.com x@example.com example-indeed@strange-example.com admin@mailserver1 FAIL example@s.example " "@example.org "john..doe"@example.org FAIL mailhost!username@example.org user%example.com@example.org invalid examples Abc.example.com FAIL A@b@c@example.com FAIL a"b(c)d,e:f;gi[j\k]l@example.com FAIL just"not"right@example.com this is"not\allowed@example.com FAIL this\ still\"not\\allowed@example.com FAIL 1234567890123456789012345678901234567890123456789012345678901234+x@example.com i_like_underscore@but_its_not_allow_in_this_part.example.com FAIL
<cfscript> function checkExamples(examples){ loop list="#examples#" item="email" delimiters="#chr(10)##chr(13)#"{ ok = isValid("email", email) if (ok) echo ("#email#<br>"); else echo ("<b>#email# FAIL</b><br>"); } echo("<hr>"); } </cfscript> <!--- examples from from https://en.wikipedia.org/wiki/Email_address#Local-part ---> <cfsavecontent variable="valid_examples"> simple@example.com very.common@example.com disposable.style.email.with+symbol@example.com other.email-with-hyphen@example.com fully-qualified-domain@example.com user.name+tag+sorting@example.com x@example.com example-indeed@strange-example.com admin@mailserver1 example@s.example " "@example.org "john..doe"@example.org mailhost!username@example.org user%example.com@example.org </cfsavecontent> <cfsavecontent variable="invalid_examples"> Abc.example.com A@b@c@example.com a"b(c)d,e:f;g<h>i[j\k]l@example.com just"not"right@example.com this is"not\allowed@example.com this\ still\"not\\allowed@example.com 1234567890123456789012345678901234567890123456789012345678901234+x@example.com i_like_underscore@but_its_not_allow_in_this_part.example.com </cfsavecontent> <h1>valid examples</h1> <cfscript> checkExamples(valid_examples); </cfscript> <h1>invalid examples</h1> <cfscript> checkExamples(invalid_examples); </cfscript>

Environment

None

Attachments

1
  • 08 Oct 2020, 08:49 am

Activity

Show:

Tony Monast 29 September 2022 at 16:04

I was wondering especially if it was normal for it to return true. From my research, an email address cannot contain spaces except between quotes. And although it works with cfmail and most mail servers, my colleague tells me that he has already had problems with his own mail server with email addresses with a space at the beginning. And if we just want to validate an email address to insert it into a database, it would be nice to be able to rely on the isValid function. But no worries, it's anecdotal and I usually trim data from forms. And quite honestly, I prefer that the resources be invested in much more important things.

Pothys - MitrahSoft 29 September 2022 at 07:04

An email has a leading space that successfully sends email with the cfmail tag in both lucee and ACF. So according to the cfmail tag behavior, isValid('email',' test@example.com') returns true is correct 🙂.

Tony Monast 28 September 2022 at 18:36
Edited

What about the email test@example.com with a leading space in it like this code

<cfdump var="#isValid('email',' test@example.com')#">

All coldfusion engines I tried on trycf return true. Is an email address that begins with a space a valid email address?

Pothys - MitrahSoft 9 October 2020 at 08:04

I've added a test case for this ticket.

Pull request: https://github.com/lucee/Lucee/pull/1060

will confirm about this issue.

Pothys - MitrahSoft 8 October 2020 at 08:51

If we try with gmail means, it showing as per below image.

Details

Assignee

Reporter

Priority

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Affects versions

Created 7 October 2020 at 13:52
Updated 29 September 2022 at 16:04

Flag notifications