Skip to content

Commit

Permalink
fix(mail(js)): parse all parameters of mailto: link
Browse files Browse the repository at this point in the history
Fixes #5478
  • Loading branch information
cgx committed Feb 8, 2022
1 parent 3ef9002 commit fa598e8
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions UI/WebServerResources/js/Mailer/Message.service.js
Expand Up @@ -662,7 +662,7 @@
action = 'markMessageUncollapse';

this.collapsed = !this.collapsed;
_this.$mailbox.updateVisibleMessages();
this.$mailbox.updateVisibleMessages();

return Message.$$resource.post(this.$absolutePath(), action).catch(function() {
this.collapsed = !this.collapsed;
Expand Down Expand Up @@ -717,32 +717,33 @@
* information parsed from the specified "mailto:" link.
*/
Message.prototype.$parseMailto = function(mailto) {
var to, data, match = /^mailto:([^\?]+)/.exec(mailto);
var to, data = {}, match = /^mailto:([^\?]+)/.exec(mailto);
if (match) {
// Recipients
to = _.map(decodeURIComponent(match[1]).split(','), function(email) {
return '<' + email.trim() + '>';
});
data = { to: to };
// Subject & body
_.forEach(['subject', 'body'], function(param) {
var re = new RegExp(param + '=([^&]+)');
param = (param == 'body')? 'text' : param;
match = re.exec(mailto);
if (match)
data[param] = decodeURIComponent(match[1]);
});
// Other Recipients
_.forEach(['cc', 'bcc'], function(param) {
var re = new RegExp(param + '=([^&]+)');
match = re.exec(mailto);
if (match)
data[param] = _.map(decodeURIComponent(match[1]).split(','), function(email) {
return '<' + email.trim() + '>';
});
});
angular.extend(this.editable, data);
}
// Subject & body
_.forEach(['subject', 'body'], function(param) {
var re = new RegExp(param + '=([^&]+)');
param = (param == 'body')? 'text' : param;
match = re.exec(mailto);
if (match)
data[param] = decodeURIComponent(match[1]);
});
// Other Recipients
_.forEach(['cc', 'bcc'], function(param) {
var re = new RegExp(param + '=([^&]+)');
match = re.exec(mailto);
if (match)
data[param] = _.map(decodeURIComponent(match[1]).split(','), function(email) {
return '<' + email.trim() + '>';
});
});
if (!_.isEmpty(data))
angular.extend(this.editable, data);
};

/**
Expand Down

0 comments on commit fa598e8

Please sign in to comment.