From ac4425ce923143d7d9d50ffed720211858b9834f Mon Sep 17 00:00:00 2001 From: Giovane Date: Mon, 23 Nov 2015 15:47:07 -0200 Subject: Fix tokenization when email has dash on domain #513 --- .../app/js/mail_view/ui/recipients/recipients_input.js | 4 ++-- .../mail_view/ui/recipients/recipients_input.spec.js | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) (limited to 'web-ui') diff --git a/web-ui/app/js/mail_view/ui/recipients/recipients_input.js b/web-ui/app/js/mail_view/ui/recipients/recipients_input.js index 7cbdad39..db0b10f7 100644 --- a/web-ui/app/js/mail_view/ui/recipients/recipients_input.js +++ b/web-ui/app/js/mail_view/ui/recipients/recipients_input.js @@ -41,8 +41,8 @@ define([ }, self; - var simpleAddressMatch = /[^<\w,;]?([^\s<;,]+@\w+\.[^\s>;,]+)/; - var canonicalAddressMatch = /([^,;\s][^,;@]+<[^\s;,]+@\w+\.[^\s;,]+>)/; + var simpleAddressMatch = /[^<\w,;]?([^\s<;,]+@[\w-]+\.[^\s>;,]+)/; + var canonicalAddressMatch = /([^,;\s][^,;@]+<[^\s;,]+@[\w-]+\.[^\s;,]+>)/; var emailAddressMatch = new RegExp([simpleAddressMatch.source, '|', canonicalAddressMatch.source].join(''), 'g'); var extractContactNames = function (response) { diff --git a/web-ui/test/spec/mail_view/ui/recipients/recipients_input.spec.js b/web-ui/test/spec/mail_view/ui/recipients/recipients_input.spec.js index 6fdf9711..829bf890 100644 --- a/web-ui/test/spec/mail_view/ui/recipients/recipients_input.spec.js +++ b/web-ui/test/spec/mail_view/ui/recipients/recipients_input.spec.js @@ -144,7 +144,7 @@ describeComponent('mail_view/ui/recipients/recipients_input',function () { }); }); - describe('when entering an invalid address', function() { + describe('validate email format', function() { var invalidAddressEnteredEvent, addressEnteredEvent, blurEvent; beforeEach(function () { @@ -187,6 +187,20 @@ describeComponent('mail_view/ui/recipients/recipients_input',function () { expect(invalidAddressEnteredEvent.calls[0].data).toEqual({name: 'to', address: 'Invalid '}); }); + it('parses email with dash' , function() { + this.$node.val('team@pixelated-project.org'); + this.$node.trigger(blurEvent); - }); + expect(blurEvent.preventDefault).toHaveBeenCalled(); + expect(addressEnteredEvent.calls[0].data).toEqual({name: 'to', address: 'team@pixelated-project.org'}); + }); + + it('parses cannonical email with dash' , function() { + this.$node.val('Pixelated '); + this.$node.trigger(blurEvent); + + expect(blurEvent.preventDefault).toHaveBeenCalled(); + expect(addressEnteredEvent.calls[0].data).toEqual({name: 'to', address: 'Pixelated '}); + }); + }); }); -- cgit v1.2.3