Bug Tracker

Ticket #2674 (assigned bug)

Opened 8 months ago

Last modified 7 months ago

[validate] Email regex broken

Reported by: sduggan Assigned to: scott.gonzalez (accepted)
Type: bug Priority: major
Milestone: 1.2.3 Component: plugin
Version: 1.2.3 Keywords: validate
Cc: Needs: Patch

Description

The regex to validate an email address seems to be faulty.

It will allow an address with a space on the end, or ending with a . or a . followed by a single character (e.g. "user@example.x").

Attachments

Change History

Changed 8 months ago by scott.gonzalez

  • owner set to scott.gonzalez
  • status changed from new to assigned

Can you provide an example of an email address that ends in a space that is being marked valid?

Changed 8 months ago by sduggan

"user@example.com " and "user@example.com." and "user@example.com. " all are validated as good email addresses...

This is using validate v 1.2.1 and jQuery 1.2.3. Tested on IE7 and Firefox 2 on Windows, and Safari on Mac. Same behaviour on the demo page at http://jquery.bassistance.de/validate/demo/

Changed 8 months ago by scott.gonzalez

The trailing space problem is actually caused by the validator trimming all data before passing it to the validation method. This explains why when I tested the validation method by itself I didn't get the same results as you. I'll talk to Jörn about this, the trimming should probably be moved into the validation methods that actually need it. I would expect this to be fixed fairly soon.

As for the other email addresses, I'll try to modify the regex to exclude those cases. They're both technically valid, but we're currently customizing the url and email regexes based on common expectation. These changes will probably take a while. If you need a quick fix, you should be able to create a new validation method that uses the email regex and also tests against /[\.]{2,}$/, this is completely untested, but makes sense in my mind :-)

Changed 7 months ago by scott.gonzalez

The trimming problem has been fixed [5305].

Note: See TracTickets for help on using tickets.