summaryrefslogtreecommitdiff
path: root/web-ui/app
diff options
context:
space:
mode:
Diffstat (limited to 'web-ui/app')
-rw-r--r--web-ui/app/js/mail_view/ui/recipients/recipients_input.js13
1 files changed, 11 insertions, 2 deletions
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 012d7fb9..4c70e180 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
@@ -33,7 +33,8 @@ define([
186: 'semicolon',
188: 'comma',
13: 'enter',
- 27: 'esc'
+ 27: 'esc',
+ 32: 'space'
},
EVENT_FOR = {
8: events.ui.recipients.deleteLast,
@@ -108,7 +109,8 @@ define([
this.recipientSelected = function (event, data) {
var value = (data && data.value) || this.$node.val();
var that = this;
- _.each(value.split(/[,;]/), function(address) {
+ var addresses = this.extractAdresses(value);
+ _.each(addresses, function(address) {
if (!_.isEmpty(address.trim())) {
that.trigger(that.$node, events.ui.recipients.entered, { name: that.attr.name, address: address.trim() });
}
@@ -116,6 +118,13 @@ define([
reset(this.$node);
};
+ this.extractAdresses = function(rawAddresses){
+ var simpleAddressMatch = /[^<\w,;]?([^\s<;,]+@[^\s>;,]+)/;
+ var canonicalAddressMatch = /([^,;\s][^,;]+<[^\s;,]+@[^\s;,]+>)/;
+ var addressMatch = new RegExp([simpleAddressMatch.source, '|', canonicalAddressMatch.source].join(''), 'g');
+ return rawAddresses.match(addressMatch);
+ };
+
this.init = function () {
this.$node.typeahead({
hint: true,