mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-08-28 17:57:38 +00:00
feat(mail): Add punycode (RFC 3492) to encode domain with special characters
This commit is contained in:
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -293,7 +293,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
return address;
|
||||
return punycode.toUnicode(address);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -341,8 +341,19 @@
|
||||
* @returns the HTML representation of the body
|
||||
*/
|
||||
Message.prototype.$content = function() {
|
||||
// Punycode
|
||||
this.to.forEach(function (element, i, arr) {
|
||||
if (element.email && element.email.indexOf('@') > 0)
|
||||
arr[i].email = punycode.toUnicode(element.email);
|
||||
});
|
||||
if (this.from && this.from.indexOf('@') > 0)
|
||||
this.from = punycode.toUnicode(this.from);
|
||||
|
||||
var _this = this,
|
||||
parts = [],
|
||||
|
||||
|
||||
|
||||
_visit = function(part) {
|
||||
part.msgclass = 'msg-attachment-other';
|
||||
if (part.type == 'UIxMailPartAlternativeViewer') {
|
||||
@@ -873,6 +884,22 @@
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* @function $punycode
|
||||
* @memberof Message.prototype
|
||||
* @desc Encode an email address string
|
||||
* @returns an RFC 3492 email encoded
|
||||
*/
|
||||
Message.prototype.punycode = function(element) {
|
||||
var re = /<(.*)>|^([\w\-\.@]+)$/gm;
|
||||
var r = re.exec(element);
|
||||
var puny = element;
|
||||
if (r && r.length > 0 && r[1]) {
|
||||
puny = r[1];
|
||||
}
|
||||
return element.replace(puny, punycode.toASCII(puny));
|
||||
};
|
||||
|
||||
/**
|
||||
* @function $send
|
||||
* @memberof Message.prototype
|
||||
@@ -885,6 +912,18 @@
|
||||
|
||||
Message.$log.debug('send = ' + JSON.stringify(data, undefined, 2));
|
||||
|
||||
// Punycode
|
||||
data.to.forEach(function (element, i, arr) {
|
||||
arr[i] = _this.punycode(element);
|
||||
});
|
||||
data.bcc.forEach(function (element, i, arr) {
|
||||
arr[i] = _this.punycode(element);
|
||||
});
|
||||
data.cc.forEach(function (element, i, arr) {
|
||||
arr[i] = _this.punycode(element);
|
||||
});
|
||||
data.from = _this.punycode(data.from);
|
||||
|
||||
return Message.$$resource.post(this.$absolutePath({asDraft: true}), 'send', data).then(function(response) {
|
||||
if (response.status == 'success') {
|
||||
if (angular.isDefined(_this.origin)) {
|
||||
|
||||
Reference in New Issue
Block a user