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

Commit 79e519f

Browse files
committed
fix(input): use Chromium's email validation regexp
This change uses the regexp from Chromium/Blink to validate emails, and corrects an error in the validation engine, which previously considered an invalid email to be valid. Additionally, the regexp was invalidating emails with capital letters, however this is not the behaviour recomended in the spec, or implemented in Chromium. Closes #5899 Closes #5924
1 parent 7cf5544 commit 79e519f

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/ng/directive/input.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*/
1010

1111
var URL_REGEXP = /^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/;
12-
var EMAIL_REGEXP = /^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,6}$/;
12+
var EMAIL_REGEXP = /^[a-z0-9!#$%&'*+/=?^_`{|}~.-]+@[a-z0-9-]+(\.[a-z0-9-]+)*$/i;
1313
var NUMBER_REGEXP = /^\s*(\-|\+)?(\d+|(\d*(\.\d*)))\s*$/;
1414

1515
var inputType = {

test/ng/directive/inputSpec.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,8 @@ describe('input', function() {
944944
it('should validate email', function() {
945945
expect(EMAIL_REGEXP.test('a@b.com')).toBe(true);
946946
expect(EMAIL_REGEXP.test('a@b.museum')).toBe(true);
947-
expect(EMAIL_REGEXP.test('a@B.c')).toBe(false);
947+
expect(EMAIL_REGEXP.test('a@B.c')).toBe(true);
948+
expect(EMAIL_REGEXP.test('a@.b.c')).toBe(false);
948949
});
949950
});
950951
});

0 commit comments

Comments
 (0)