Make WordPress Core

Opened 2 years ago

Last modified 11 months ago

#55821 new defect (bug)

`is_email()` does not follow PHP FILTER_VALIDATE_EMAIL rules, when an email has double period (..)

Reported by: khokansardar's profile khokansardar Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.9.3
Component: Formatting Keywords: has-testing-info has-patch has-unit-tests
Focuses: Cc:

Description

If there has a typo in an email address like there has double period .. in an email address ( abc..def@… ). is_email() function return valid email when we have use like -

is_email( 'abc..def@xyz.com' )

Where it should not return as valid email address. Which is working with PHP FILTER_VALIDATE_EMAIL checking. When we are checking the same kind of email with below code it return boolean false.

filter_var( 'abc..def@xyz.com', FILTER_VALIDATE_EMAIL )

Expected behaviour should be like this. When use is_email() function it should respect like what PHP does.

Change History (6)

#1 @khokansardar
2 years ago

  • Severity changed from normal to major

#2 @desrosj
2 years ago

  • Severity changed from major to normal

#3 @Boniu91
2 years ago

Testing Instructions

These steps define how to reproduce the issue, and indicate the expected behavior.

Steps to Reproduce

  1. Add the following code to the footer.php, before closing </html> https://snippi.com/s/8gji8lp
  2. Visit the page and check the footer
  3. 🐞 Bug occurs, email address is valid is displayed

Expected Results

When testing a patch to validate it works as expected:

  • 3rd point should display email address is not valid.

Additionaly

We could change the abc..def@xyz.com to other not valid emails and see the results.

#4 @Boniu91
2 years ago

  • Keywords has-testing-info added

#5 @khokansardar
14 months ago

  • Keywords needs-patch added

This ticket was mentioned in PR #4631 on WordPress/wordpress-develop by @lopo.


11 months ago
#6

  • Keywords has-patch has-unit-tests added; needs-patch removed

Added a check for double periods on the local part of the email address (taking inspiration from the same check on the domain part) + added unit test cases for both the local and the domain part (which was missing).

Trac ticket: https://core.trac.wordpress.org/ticket/55821

Note: See TracTickets for help on using tickets.