From f7686b7db88da4f7d9677f6dcbe0c40c00ee022f Mon Sep 17 00:00:00 2001 From: Mechiel Lukkien Date: Wed, 1 Nov 2023 19:12:52 +0100 Subject: [PATCH] webmail: show email address instead of display name of "from" header in message listing if display name contains chars from "<@>" it could be an attempt to confuse the reader with an email address. a classic. --- webmail/lib.ts | 7 ++++--- webmail/msg.js | 7 ++++--- webmail/text.js | 7 ++++--- webmail/webmail.js | 7 ++++--- webmail/webmail.ts | 2 +- 5 files changed, 17 insertions(+), 13 deletions(-) diff --git a/webmail/lib.ts b/webmail/lib.ts index cbb50a6..3368870 100644 --- a/webmail/lib.ts +++ b/webmail/lib.ts @@ -316,10 +316,11 @@ const formatAddressFull = (a: api.MessageAddress): string => { return s } -// format just the name, or otherwies just the email address. +// format just the name if present and it doesn't look like an address, or otherwise just the email address. const formatAddressShort = (a: api.MessageAddress): string => { - if (a.Name) { - return a.Name + const n = a.Name + if (n && !n.includes('<') && !n.includes('@') && !n.includes('>')) { + return n } return '<' + a.User + '@' + a.Domain.ASCII + '>' } diff --git a/webmail/msg.js b/webmail/msg.js index a730370..9edbfc4 100644 --- a/webmail/msg.js +++ b/webmail/msg.js @@ -959,10 +959,11 @@ const formatAddressFull = (a) => { } return s; }; -// format just the name, or otherwies just the email address. +// format just the name if present and it doesn't look like an address, or otherwise just the email address. const formatAddressShort = (a) => { - if (a.Name) { - return a.Name; + const n = a.Name; + if (n && !n.includes('<') && !n.includes('@') && !n.includes('>')) { + return n; } return '<' + a.User + '@' + a.Domain.ASCII + '>'; }; diff --git a/webmail/text.js b/webmail/text.js index adf2a4f..fbe7e43 100644 --- a/webmail/text.js +++ b/webmail/text.js @@ -959,10 +959,11 @@ const formatAddressFull = (a) => { } return s; }; -// format just the name, or otherwies just the email address. +// format just the name if present and it doesn't look like an address, or otherwise just the email address. const formatAddressShort = (a) => { - if (a.Name) { - return a.Name; + const n = a.Name; + if (n && !n.includes('<') && !n.includes('@') && !n.includes('>')) { + return n; } return '<' + a.User + '@' + a.Domain.ASCII + '>'; }; diff --git a/webmail/webmail.js b/webmail/webmail.js index b436684..698b739 100644 --- a/webmail/webmail.js +++ b/webmail/webmail.js @@ -959,10 +959,11 @@ const formatAddressFull = (a) => { } return s; }; -// format just the name, or otherwies just the email address. +// format just the name if present and it doesn't look like an address, or otherwise just the email address. const formatAddressShort = (a) => { - if (a.Name) { - return a.Name; + const n = a.Name; + if (n && !n.includes('<') && !n.includes('@') && !n.includes('>')) { + return n; } return '<' + a.User + '@' + a.Domain.ASCII + '>'; }; diff --git a/webmail/webmail.ts b/webmail/webmail.ts index 17532a8..13b7a79 100644 --- a/webmail/webmail.ts +++ b/webmail/webmail.ts @@ -1744,7 +1744,7 @@ interface MsgitemView { // Sub messages in thread. Can be further descendants, when an intermediate message // is missing. kids: MsgitemView[] - // Whether this thread root is collapsed. If so, the root is visible, all descedants + // Whether this thread root is collapsed. If so, the root is visible, all descendants // are not. Value is only valid if this is a thread root. collapsed: boolean