- Merge request !10Issue #3327190: Email validation: do not authorize email like xx@xx → (Open) created by Grimreaper
Thank you for the patch. I was having issues with forms submitting with email adress just like that and triggering wierd errors on the server side. This fixed it.
I am using drupal 9.7 and php 7.4.
- 🇫🇷France Striknin Lyon
Hi, thanks for this usefull patch.
But what about email addresses with subdomain, like XXX@sub.domain.ext ?We need to allow repeated segments with dots, after the @.
So, by changing the regex by the one proposed in this new patch, the validation passes for email addresses with subdomain. - Assigned to Grimreaper
- Status changed to Needs work
over 1 year ago 11:05am 10 May 2023 - 🇫🇷France Grimreaper France 🇫🇷
Hi,
@Striknin, thanks for the patch, this is a case I am encountering on my project too.
But with this patch, xx@xx is now valid again which was the original point of the issue.
I will update the MR.
- last update
over 1 year ago 1 pass - last update
over 1 year ago 1 pass - Status changed to Needs review
over 1 year ago 11:21am 10 May 2023 - 🇫🇷France Grimreaper France 🇫🇷
This is regex from Jquery library:
return this.optional( element ) || /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test( value );
This is the new proposed one:
return this.optional( element ) || /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+$/.test( value );
I removed the "?" to have a first domain part. And changed the "*" to "+" to have any depth of subdomains. But with at last a first level.
xxx@xxx => FALSE
xxx@xxx.xxx => OK
xxx@xxx.xxx.xxx => OKetc.
- Issue was unassigned.
- last update
over 1 year ago 1 pass - 🇫🇷France Striknin Lyon
Hello,
@Grimreaper you're absolutely right! My bad, I didn't re-check after changing the regex ...
It's now perfect, thank you ! - Status changed to RTBC
over 1 year ago 7:23am 23 May 2023 - 🇫🇷France Grimreaper France 🇫🇷
@Striknin, thanks to have re-tested.
Changing to RTBC regarding comment 9.
- 🇦🇺Australia Nigel Cunningham Geelong
Would it be feasible to make the change optional? Sometimes, such as when testing in the context of a local development environment, you might validly want to just enter user@localhost.
Regards,
Nigel
- Status changed to Needs work
12 months ago 3:56am 11 December 2023 - 🇮🇳India nikunjkotecha India, Gujarat, Rajkot
I agree, changing the validation should be based on configuration.
- First commit to issue fork.
- last update
12 months ago 1 pass - Status changed to Needs review
12 months ago 10:38am 11 December 2023 - 🇮🇳India sakthi_dev
Made the jquery over ride based on config. Please review.