Skip to content

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 angular#5899 Closes angular#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('[email protected]')).toBe(true);
946946
expect(EMAIL_REGEXP.test('[email protected]')).toBe(true);
947-
expect(EMAIL_REGEXP.test('[email protected]')).toBe(false);
947+
expect(EMAIL_REGEXP.test('[email protected]')).toBe(true);
948+
expect(EMAIL_REGEXP.test('[email protected]')).toBe(false);
948949
});
949950
});
950951
});

0 commit comments

Comments
 (0)