Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
fix(input): modify email validation regexp to match rfc1035
Browse files Browse the repository at this point in the history
Previously, domain parts which began with or ended with a dash, would be accepted as valid. This CL matches Angular's email validation with that of Chromium and Firefox.

Closes #6026
  • Loading branch information
KevinBrogan authored and caitp committed Jul 7, 2014
1 parent 0a51a05 commit af6f943
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ng/directive/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/

var URL_REGEXP = /^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/;
var EMAIL_REGEXP = /^[a-z0-9!#$%&'*+\/=?^_`{|}~.-]+@[a-z0-9-]+(\.[a-z0-9-]+)*$/i;
var EMAIL_REGEXP = /^[a-z0-9!#$%&'*+/=?^_`{|}~.-]+@[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$/i;
var NUMBER_REGEXP = /^\s*(\-|\+)?(\d+|(\d*(\.\d*)))\s*$/;
var DATE_REGEXP = /^(\d{4})-(\d{2})-(\d{2})$/;
var DATETIMELOCAL_REGEXP = /^(\d{4})-(\d\d)-(\d\d)T(\d\d):(\d\d)$/;
Expand Down
4 changes: 4 additions & 0 deletions test/ng/directive/inputSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2366,6 +2366,10 @@ describe('input', function() {
expect(EMAIL_REGEXP.test('a@b.museum')).toBe(true);
expect(EMAIL_REGEXP.test('a@B.c')).toBe(true);
expect(EMAIL_REGEXP.test('a@.b.c')).toBe(false);
expect(EMAIL_REGEXP.test('a@-b.c')).toBe(false);
expect(EMAIL_REGEXP.test('a@b-.c')).toBe(false);
expect(EMAIL_REGEXP.test('a@3b.c')).toBe(true);
expect(EMAIL_REGEXP.test('a@b')).toBe(true);
});
});
});
Expand Down

0 comments on commit af6f943

Please sign in to comment.