Skip to content

Commit

Permalink
Merge pull request #32281 from owncloud/stable10-validate-email-regex
Browse files Browse the repository at this point in the history
[stable10] Backport of Change regex to accept subdomains with hyphens.
  • Loading branch information
phil-davis authored Aug 9, 2018
2 parents 90ab9f7 + 70c3694 commit 94a0923
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/js/sharedialogmailview.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
if (email.length === 0)
return true

return email.match(/([\w\.\-_]+)?\w+@[\w-_]+(\.\w+){1,}$/);
return email.match(/^[A-Za-z0-9\._%+-]+@(?:[A-Za-z0-9-]+\.)+[a-z]{2,}$/);
},

sendEmails: function() {
Expand Down
13 changes: 13 additions & 0 deletions core/js/tests/specs/sharedialogmailviewSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,19 @@ describe('OC.Share.ShareDialogMailView', function() {
});
});

describe('validating addresses', function() {
it('works as expected', function() {
expect(view.validateEmail('[email protected]')[0]).toEqual('[email protected]');
expect(view.validateEmail('[email protected]')[0]).toEqual('[email protected]');
expect(view.validateEmail('[email protected]')[0]).toEqual('[email protected]');
expect(view.validateEmail('[email protected]')[0]).toEqual('[email protected]');

expect(view.validateEmail('[email protected]')).toEqual(null);
expect(view.validateEmail('Jill.Valentine@um#rella.com')).toEqual(null);
expect(view.validateEmail('Jürgen.Sö[email protected]')).toEqual(null);
});
});

describe('sending emails', function() {
var clock;

Expand Down

0 comments on commit 94a0923

Please sign in to comment.