diff --git a/dev/Model/Email.js b/dev/Model/Email.js index 61b5ed2c5..2536e39d4 100644 --- a/dev/Model/Email.js +++ b/dev/Model/Email.js @@ -1,3 +1,4 @@ +import { encodeHtml } from 'Common/Html'; import { AbstractModel } from 'Knoin/AbstractModel'; @@ -332,13 +333,31 @@ export class EmailModel extends AbstractModel { /** * @param {boolean} friendlyView = false + * @param {boolean} wrapWithLink = false * @returns {string} */ - toLine(friendlyView) { - let result = this.email; - return (result && this.name) - ? (friendlyView ? this.name : '"' + this.name + '" <' + result + '>') - : result; + toLine(friendlyView, wrapWithLink) { + let result = this.email, + name = this.name, + toLink = text => + '') : '') + + '" target="_blank" tabindex="-1">' + + encodeHtml(text || result) + + ''; + if (result) { + if (name) { + result = friendlyView + ? (wrapWithLink ? toLink(name) : name) + : (wrapWithLink + ? encodeHtml('"' + name + '" <') + toLink() + encodeHtml('>') + : '"' + name + '" <' + result + '>' + ); + } else if (wrapWithLink) { + result = toLink(); + } + } + return result; } static splitEmailLine(line) { diff --git a/dev/Model/EmailCollection.js b/dev/Model/EmailCollection.js index 5e4744ef8..a0b904d30 100644 --- a/dev/Model/EmailCollection.js +++ b/dev/Model/EmailCollection.js @@ -18,10 +18,8 @@ export class EmailCollectionModel extends AbstractCollectionModel * @param {boolean=} wrapWithLink = false * @returns {string} */ - toString(friendlyView = false, wrapWithLink = false) { - const result = []; - this.forEach(email => result.push(email.toLine(friendlyView, wrapWithLink))); - return result.join(', '); + toString(friendlyView, wrapWithLink) { + return this.map(email => email.toLine(friendlyView, wrapWithLink)).join(', '); } /** diff --git a/dev/Model/Message.js b/dev/Model/Message.js index bfb99e8fd..440259b27 100644 --- a/dev/Model/Message.js +++ b/dev/Model/Message.js @@ -349,21 +349,17 @@ export class MessageModel extends AbstractModel { } /** - * @param {boolean} friendlyView - * @param {boolean=} wrapWithLink * @returns {string} */ - bccToLine(friendlyView, wrapWithLink) { - return this.bcc.toString(friendlyView, wrapWithLink); + bccToLine() { + return this.bcc.toString(); } /** - * @param {boolean} friendlyView - * @param {boolean=} wrapWithLink * @returns {string} */ - replyToToLine(friendlyView, wrapWithLink) { - return this.replyTo.toString(friendlyView, wrapWithLink); + replyToToLine() { + return this.replyTo.toString(); } /** @@ -508,7 +504,7 @@ export class MessageModel extends AbstractModel { viewPopupMessage(print) { const timeStampInUTC = this.dateTimeStampInUTC() || 0, - ccLine = this.ccToLine(false), + ccLine = this.ccToLine(), m = 0 < timeStampInUTC ? new Date(timeStampInUTC * 1000) : null, win = open(''), sdoc = win.document; @@ -520,7 +516,7 @@ export class MessageModel extends AbstractModel { sdoc.write(PreviewHTML .replace('