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('', '<title>'+subject) // eslint-disable-next-line max-len - .replace('<body>', `<body style="background-color:${prop('background-color')};color:${prop('color')}"><header><h1>${subject}</h1><time>${encodeHtml(m ? m.format('LLL') : '')}</time><div>${encodeHtml(this.fromToLine(false))}</div><div>${encodeHtml(i18n('GLOBAL/TO'))}: ${encodeHtml(this.toToLine(false))}</div>${cc}</header><${mode}>${this.bodyAsHTML()}</${mode}>`) + .replace('<body>', `<body style="background-color:${prop('background-color')};color:${prop('color')}"><header><h1>${subject}</h1><time>${encodeHtml(m ? m.format('LLL') : '')}</time><div>${encodeHtml(this.fromToLine())}</div><div>${encodeHtml(i18n('GLOBAL/TO'))}: ${encodeHtml(this.toToLine())}</div>${cc}</header><${mode}>${this.bodyAsHTML()}</${mode}>`) ); sdoc.close(); diff --git a/dev/View/User/MailBox/MessageView.js b/dev/View/User/MailBox/MessageView.js index e165ca065..04c585f22 100644 --- a/dev/View/User/MailBox/MessageView.js +++ b/dev/View/User/MailBox/MessageView.js @@ -252,11 +252,10 @@ export class MailMessageView extends AbstractViewRight { ThemeStore.isMobile() && leftPanelDisabled(true); let el = eqs(event, 'a'); - if (el) { - return !( - 0 === event.button && - mailToHelper(el.href) - ); + if (el && 0 === event.button && mailToHelper(el.href)) { + event.preventDefault(); + event.stopPropagation(); + return; } if (eqs(event, '.attachmentsPlace .attachmentIconParent')) {