Warn about suspicious mail senders and links

Bump version to 0.1.21

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
2026-10-07 01:53:01 +03:00
co-authored by Copilot
parent cae6825f2c
commit bfeda83e07
15 changed files with 284 additions and 13 deletions
+1 -1
View File
@@ -4,7 +4,7 @@ An Eternity Project mail client with **Eternity Daylight**, **Wasteland**, and E
## Desktop app
The Electron app runs in its own window. With Node.js installed, run `npm install` and then `npm start`. Open **Mail account settings** to connect an IMAP/SMTP account. Each account can have its own outgoing signature, new-mail notification toggle, periodic sync interval (2–60 minutes; IDLE remains event-driven), and mail rules. Rules match incoming Inbox messages by sender and/or subject; the first matching rule archives, moves to Inbox/Archive/Trash, applies a label, or flags the message. Settings, cached recent messages, offline drafts, and queued mail operations are stored with the encrypted account credentials. Search supports text, sender, subject, date range, attachment, and folder filters; a filtered online search scans up to the newest 5,000 messages in the selected folder. When offline, the app can read cached messages, save drafts, and queue supported message actions and sends for retry on the next successful sync. The app uses required STARTTLS for IMAP port 143 and SMTP port 587. Before preparing a new release, bump the version once with `npm run bump:build`; then build all platform targets for that same version. To package it on Windows, run `npm run dist:win`; the installer and portable `.exe` are written to `release/`. To package on Linux, run `npm install` and `npm run dist:linux` on a Linux machine; this produces AppImage and Debian packages in `release/`.
The Electron app runs in its own window. With Node.js installed, run `npm install` and then `npm start`. Open **Mail account settings** to connect an IMAP/SMTP account. Each account can have its own outgoing signature, new-mail notification toggle, periodic sync interval (2–60 minutes; IDLE remains event-driven), and mail rules. Rules match incoming Inbox messages by sender and/or subject; the first matching rule archives, moves to Inbox/Archive/Trash, applies a label, or flags the message. Sender/domain and extracted message-link checks highlight selected phishing warning signs. Message links are shown separately from the body and require explicit confirmation before opening in a browser; the app never renders remote message HTML. Settings, cached recent messages, offline drafts, and queued mail operations are stored with the encrypted account credentials. Search supports text, sender, subject, date range, attachment, and folder filters; a filtered online search scans up to the newest 5,000 messages in the selected folder. When offline, the app can read cached messages, save drafts, and queue supported message actions and sends for retry on the next successful sync. The app uses required STARTTLS for IMAP port 143 and SMTP port 587. Before preparing a new release, bump the version once with `npm run bump:build`; then build all platform targets for that same version. To package it on Windows, run `npm run dist:win`; the installer and portable `.exe` are written to `release/`. To package on Linux, run `npm install` and `npm run dist:linux` on a Linux machine; this produces AppImage and Debian packages in `release/`.
The `.github/workflows/desktop-build.yml` workflow builds both Windows and Linux artifacts on their native GitHub-hosted runners when manually started from the Actions tab. Snoozed messages return to their original mailbox with a reminder; desktop reminders are checked while the app is running, and Android uses its periodic background worker.
+2 -1
View File
@@ -17,9 +17,10 @@
- [ ] Group related messages into conversations, with controls to expand or collapse threads.
- [ ] Add attachment previews and a dedicated view to find and manage attachments across mailboxes.
- [ ] Add configurable keyboard shortcuts for common actions such as compose, archive, reply, and search.
- [ ] Add warnings for suspicious sender addresses and links before opening potentially unsafe content.
- [x] Warn about suspicious sender addresses and links; require confirmation before opening external links.
- [x] Add per-account rules to sort, archive, label, or flag new incoming messages by sender and/or subject.
- [x] Add per-account signatures, notification preferences, and sync settings.
- [ ] Add the ability to create IMAP folders from the app.
- [ ] Block remote images by default and let users load them per message.
## Mail security
@@ -528,7 +528,8 @@ internal object AndroidMailService {
val subject = decode(message.subject).ifBlank { "(no subject)" }
val body = ArrayList<String>()
val attachments = JSONArray()
collectParts(message, body, attachments)
val links = linkedSetOf<String>()
collectParts(message, body, attachments, links)
val bodyText = body.joinToString("\n\n").trim().take(8000)
val snippet = (bodyText.ifBlank { subject }).replace(Regex("\\s+"), " ").take(180)
val date = message.receivedDate ?: message.sentDate ?: Date()
@@ -567,6 +568,7 @@ internal object AndroidMailService {
val paragraphs = bodyText.split(Regex("\\n\\s*\\n")).map(String::trim).filter(String::isNotEmpty).take(40)
if (paragraphs.isEmpty()) put("This message has no plain-text body.") else paragraphs.forEach(::put)
})
.put("links", JSONArray().apply { links.take(30).forEach(::put) })
.put("attachments", attachments)
.put("attachment", files.firstOrNull()?.optString("filename") ?: JSONObject.NULL)
.put("size", files.firstOrNull()?.optString("size") ?: "")
@@ -575,7 +577,7 @@ internal object AndroidMailService {
private fun attachmentList(attachments: JSONArray): List<JSONObject> =
(0 until attachments.length()).map { attachments.getJSONObject(it) }
private fun collectParts(part: javax.mail.Part, body: MutableList<String>, attachments: JSONArray) {
private fun collectParts(part: javax.mail.Part, body: MutableList<String>, attachments: JSONArray, links: MutableSet<String>) {
val filename = decode(part.fileName)
if (filename.isNotBlank() || part.disposition.equals(javax.mail.Part.ATTACHMENT, true)) {
val name = filename.ifBlank { "attachment" }
@@ -587,13 +589,18 @@ internal object AndroidMailService {
when (content) {
is String -> if (part.isMimeType("text/plain")) {
body.add(content.replace("\r", "").trim())
} else if (part.isMimeType("text/html") && body.isEmpty()) {
body.add(Html.fromHtml(content, Html.FROM_HTML_MODE_LEGACY).toString().trim())
} else if (part.isMimeType("text/html")) {
Regex("""<a\b[^>]*\bhref\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))""", RegexOption.IGNORE_CASE)
.findAll(content)
.mapNotNull { match -> (match.groups[1]?.value ?: match.groups[2]?.value ?: match.groups[3]?.value)?.replace("&amp;", "&") }
.take(30)
.forEach(links::add)
if (body.isEmpty()) body.add(Html.fromHtml(content, Html.FROM_HTML_MODE_LEGACY).toString().trim())
}
is Multipart -> for (index in 0 until content.count) {
collectParts(content.getBodyPart(index), body, attachments)
collectParts(content.getBodyPart(index), body, attachments, links)
}
is javax.mail.BodyPart -> collectParts(content, body, attachments)
is javax.mail.BodyPart -> collectParts(content, body, attachments, links)
}
}
@@ -4,7 +4,9 @@ import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.net.Uri
import android.os.Build
import android.app.AlertDialog
import com.getcapacitor.JSObject
import com.getcapacitor.Plugin
import com.getcapacitor.PluginCall
@@ -224,6 +226,34 @@ class EpMailPlugin : Plugin() {
}
}
@PluginMethod
fun openExternal(call: PluginCall) {
val raw = call.getString("url").orEmpty()
val uri = runCatching { Uri.parse(raw) }.getOrNull()
if (uri == null || uri.scheme?.lowercase(Locale.ROOT) !in setOf("http", "https") ||
uri.host.isNullOrBlank() || uri.userInfo != null) {
call.reject("Only standard web links can be opened from mail.")
return
}
AlertDialog.Builder(activity)
.setTitle("Open external link?")
.setMessage("Email links can lead to fake sign-in pages or harmful content.\n\nCheck the full address before continuing:\n${uri}")
.setNegativeButton("Cancel") { _, _ -> call.resolve(JSObject().put("opened", false)) }
.setPositiveButton("Open link") { _, _ ->
try {
val intent = Intent(Intent.ACTION_VIEW, uri)
activity.startActivity(intent)
call.resolve(JSObject().put("opened", true))
} catch (_: android.content.ActivityNotFoundException) {
call.reject("No browser is available to open this link.")
} catch (error: Exception) {
call.reject(error.message ?: "Could not open the link.")
}
}
.setOnCancelListener { call.resolve(JSObject().put("opened", false)) }
.show()
}
@PluginMethod
fun send(call: PluginCall) {
val input = JSONObject(call.data.toString()).apply {
+33 -2
View File
@@ -513,6 +513,11 @@ async function toUiMessage(item, folder) {
const bodyText = String(parsed.text || '').replace(/\r/g, '').trim().slice(0, 20000);
const body = bodyText ? bodyText.split(/\n\s*\n/).map(part => part.trim()).filter(Boolean).slice(0, 40) : ['This message has no plain-text body.'];
const date = parsed.date || item.internalDate || new Date();
const html = Array.isArray(parsed.html) ? parsed.html.join('') : String(parsed.html || '');
const links = [...html.matchAll(/<a\b[^>]*\bhref\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/gi)]
.map(match => (match[1] || match[2] || match[3] || '').replace(/&amp;/gi, '&').replace(/&#x2f;/gi, '/'))
.filter(Boolean)
.slice(0, 30);
return {
id: Number(item.uid),
initials: (sender?.name || sender?.address || '?').split(/[\s@]+/).filter(Boolean).map(word => word[0]).join('').slice(0, 2).toUpperCase(),
@@ -532,6 +537,7 @@ async function toUiMessage(item, folder) {
deleted: folder === 'Trash',
sourceFolder: folder,
body,
links,
uid: Number(item.uid),
attachments: (parsed.attachments || []).map(file => ({ filename: file.filename || 'attachment', size: file.size || 0 })),
attachment: parsed.attachments?.[0]?.filename || null,
@@ -1097,6 +1103,32 @@ ipcMain.handle('mail:save-attachment', async (event, input) => {
}
});
ipcMain.handle('mail:open-external', async (event, rawUrl) => {
let target;
try {
target = new URL(String(rawUrl || ''));
} catch {
throw new Error('This link is not a valid web address.');
}
if (!['http:', 'https:'].includes(target.protocol) || target.username || target.password) {
throw new Error('Only standard web links can be opened from mail.');
}
const parent = BrowserWindow.fromWebContents(event.sender);
const confirmation = await dialog.showMessageBox(parent, {
type: 'warning',
title: 'Open external link?',
message: 'Email links can lead to fake sign-in pages or harmful content.',
detail: `Check the full address before continuing:\n${target.href}`,
buttons: ['Cancel', 'Open link'],
defaultId: 0,
cancelId: 0,
noLink: true
});
if (confirmation.response !== 1) return { opened: false };
await shell.openExternal(target.href);
return { opened: true };
});
ipcMain.handle('mail:sync-inbox', async () => {
const account = await readAccount();
if (!account) throw new Error('Add a mail account before syncing.');
@@ -1356,8 +1388,7 @@ function createWindow() {
window.once('ready-to-show', () => window.show());
window.loadFile(path.join(__dirname, '..', 'index.html'));
window.webContents.setWindowOpenHandler(({ url }) => {
if (url.startsWith('https://') || url.startsWith('mailto:')) shell.openExternal(url);
window.webContents.setWindowOpenHandler(() => {
return { action: 'deny' };
});
window.webContents.on('will-navigate', (event, url) => {
+1
View File
@@ -17,6 +17,7 @@ contextBridge.exposeInMainWorld('daybreakMail', {
updateMessage: details => ipcRenderer.invoke('mail:update-message', details),
setSnooze: details => ipcRenderer.invoke('mail:set-snooze', details),
saveAttachment: details => ipcRenderer.invoke('mail:save-attachment', details),
openExternal: url => ipcRenderer.invoke('mail:open-external', url),
send: message => ipcRenderer.invoke('mail:send', message),
disconnect: id => ipcRenderer.invoke('mail:disconnect', id),
davList: () => ipcRenderer.invoke('dav:list'),
+96
View File
@@ -6,6 +6,102 @@ let mailboxSyncQueued = false;
let mailboxRefreshPending = false;
let folderBeforeSearch = null;
const senderBrandDomains = {
amazon: ['amazon.com', 'amazon.co.uk'],
apple: ['apple.com', 'icloud.com'],
google: ['google.com', 'gmail.com'],
microsoft: ['microsoft.com', 'outlook.com', 'live.com'],
paypal: ['paypal.com']
};
function suspiciousSenderReasons(message) {
const email = String(message.email || '').trim().toLowerCase();
const domain = email.split('@').pop() || '';
if (!domain) return [];
const reasons = [];
if (domain.includes('xn--')) reasons.push('The sender address uses an internationalized domain that may imitate another domain.');
const name = String(message.sender || '').toLowerCase();
for (const [brand, domains] of Object.entries(senderBrandDomains)) {
const brandName = new RegExp(`^(?:the\\s+)?${brand}(?:\\s+(?:customer\\s+service|support|security|account|billing|team|payments?|services?))*$`, 'i');
if (brandName.test(name) && !domains.some(allowed => domain === allowed || domain.endsWith(`.${allowed}`))) {
reasons.push(`The display name mentions ${brand}, but the sender domain is ${domain}.`);
}
}
if (/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(name) && name.split('@').pop() !== domain) {
reasons.push('The address-like display name does not match the actual sender domain.');
}
return [...new Set(reasons)];
}
function inspectMailLink(raw) {
const cleaned = String(raw).replace(/[.,!?;:)\]}>"']+$/g, '');
let parsed;
try { parsed = new URL(cleaned); } catch { return null; }
if (!['http:', 'https:'].includes(parsed.protocol) || parsed.username || parsed.password) return null;
const host = parsed.hostname.toLowerCase();
const reasons = [];
if (parsed.protocol === 'http:') reasons.push('unencrypted HTTP connection');
if (host.includes('xn--')) reasons.push('internationalized domain that may imitate another address');
if (/^(?:\d{1,3}\.){3}\d{1,3}$/.test(host) || host.startsWith('[')) reasons.push('IP-address destination instead of a named website');
if (['bit.ly', 't.co', 'tinyurl.com', 'is.gd', 'lnkd.in'].includes(host)) reasons.push('shortened link hides its final destination');
for (const [brand, domains] of Object.entries(senderBrandDomains)) {
const mentionsBrand = new RegExp(`(^|[.-])${brand.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')}([.-]|$)`, 'i').test(host);
if (mentionsBrand && !domains.some(domain => host === domain || host.endsWith(`.${domain}`))) {
reasons.push(`hostname mentions ${brand} without using its usual domain`);
}
}
return { url: parsed.href, host, reasons };
}
function messageLinks(message) {
const bodyLinks = (message.body || []).join('\n').match(/https?:\/\/[^\s<>"']+/gi) || [];
const declaredLinks = Array.isArray(message.links) ? message.links : [];
return [...new Set([...bodyLinks, ...declaredLinks])]
.map(inspectMailLink)
.filter(Boolean)
.slice(0, 30);
}
const originalOpenMessage = openMessage;
openMessage = function (id) {
originalOpenMessage(id);
const message = messages.find(item => item.id === id);
if (!message) return;
const senderReasons = suspiciousSenderReasons(message);
const links = messageLinks(message);
const warnings = [];
if (senderReasons.length) {
warnings.push(`<section class="mail-safety-warning" role="alert"><strong>Sender details may be misleading</strong><ul>${senderReasons.map(reason => `<li>${esc(reason)}</li>`).join('')}</ul><small>Sender names and addresses can be forged. Verify the sender through a trusted channel.</small></section>`);
}
const linkCards = links.map((link, index) => `
<div class="mail-link-row ${link.reasons.length ? 'mail-link-risky' : ''}">
<div><strong>${link.reasons.length ? 'Potentially unsafe link' : 'External link'}</strong><span>${esc(link.host)}</span>
${link.reasons.length ? `<small>${esc(link.reasons.join('; '))}</small>` : ''}</div>
<button type="button" class="mail-link-open" data-mail-link="${index}">Review &amp; open</button>
</div>`).join('');
const reader = $('#reader-pane');
const header = reader.querySelector('.reader-header');
if (warnings.length && header) header.insertAdjacentHTML('afterend', warnings.join(''));
const replyBar = reader.querySelector('.reply-bar');
if (links.length && replyBar) {
replyBar.insertAdjacentHTML('beforebegin', `<section class="mail-links"><h3>Links in this message</h3>${links.some(link => link.reasons.length) ? '<p class="mail-safety-intro">Some links show warning signs. Every link requires confirmation before it opens.</p>' : ''}${linkCards}</section>`);
reader.querySelectorAll('[data-mail-link]').forEach(button => {
button.onclick = async () => {
const link = links[Number(button.dataset.mailLink)];
if (!link) return;
button.disabled = true;
try {
await window.daybreakMail.openExternal(link.url);
} catch (error) {
toast(error.message || 'Could not open this link');
} finally {
button.disabled = false;
}
};
});
}
};
function updateAccountCard(account) {
const card = $('#account-settings');
if (!card) return;
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "ep-mail",
"version": "0.1.20",
"version": "0.1.21",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "ep-mail",
"version": "0.1.20",
"version": "0.1.21",
"dependencies": {
"@capacitor/android": "^8.5.2",
"@capacitor/core": "^8.5.2",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "ep-mail",
"version": "0.1.20",
"version": "0.1.21",
"private": true,
"description": "Eternity Project mail client",
"author": "Eternity Project",
+1
View File
@@ -529,6 +529,7 @@
setSnooze: (details) => EpMail.setSnooze(details),
checkSnoozeReminders: () => EpMail.checkSnoozeReminders(),
saveAttachment: (details) => EpMail.saveAttachment(details),
openExternal: (url) => EpMail.openExternal({ url }),
send: (message) => EpMail.send(message),
disconnect: (id) => EpMail.removeAccount({ id }),
davList: () => EpMail.davList(),
+1
View File
@@ -21,6 +21,7 @@ if (Capacitor.isNativePlatform() && Capacitor.getPlatform() === 'android') {
setSnooze: details => EpMail.setSnooze(details),
checkSnoozeReminders: () => EpMail.checkSnoozeReminders(),
saveAttachment: details => EpMail.saveAttachment(details),
openExternal: url => EpMail.openExternal({ url }),
send: message => EpMail.send(message),
disconnect: id => EpMail.removeAccount({ id }),
davList: () => EpMail.davList(),
+3
View File
@@ -121,3 +121,6 @@ body.ep-daylight .row-check:checked{accent-color:#526a2c}
.search-filters{position:absolute;right:78px;top:calc(100% + 8px);z-index:12;display:grid;grid-template-columns:1fr 1fr;gap:10px;width:min(360px,calc(100vw - 32px));padding:14px;border:1px solid var(--border,#d8ddd5);border-radius:12px;background:var(--panel,#fff);box-shadow:0 8px 28px #17201724}.search-filters.hidden{display:none}.search-filters label{display:grid;gap:4px;font-size:12px}.search-filters input,.search-filters select{min-width:0;border:1px solid var(--border,#d8ddd5);border-radius:7px;padding:7px;background:transparent;color:inherit;font:inherit}.search-filters .filter-checkbox{display:flex;align-items:center;gap:7px}.search-filters .filter-checkbox input{min-width:auto}.search-filters .text-button{grid-column:1/-1;justify-self:start}.top-actions{position:relative}
body.ep-wasteland .search-filters{background:#211c18;border-color:#4a3f33;color:#d4cbbc}body.ep-wasteland .search-filters input,body.ep-wasteland .search-filters select{border-color:#4a3f33;color:#d4cbbc}
body.ep-daylight .search-filters{background:#fbfbf6;border-color:#b9c5bc;color:#263a3d}
.mail-safety-warning{margin:10px 16px;padding:12px 14px;border:1px solid #d69b43;border-left:4px solid #b87321;border-radius:8px;background:#fff6df;color:#5b3c17;font-size:12px}.mail-safety-warning strong{display:block}.mail-safety-warning ul{margin:7px 0;padding-left:18px}.mail-safety-warning small{display:block;line-height:1.4}.mail-links{padding:12px 16px;border-top:1px solid var(--line,#eaede8)}.mail-links h3{margin:0 0 8px;font-size:12px}.mail-safety-intro{font-size:11px;color:#8d4a16}.mail-link-row{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:9px 10px;margin-top:6px;border:1px solid var(--line,#eaede8);border-radius:8px;font-size:11px}.mail-link-row>div{min-width:0;display:grid;gap:3px}.mail-link-row span,.mail-link-row small{overflow-wrap:anywhere;color:#727970}.mail-link-risky{border-color:#d69b43;background:#fff8ea}.mail-link-open{flex:none;border:1px solid #9ba99b;border-radius:6px;background:transparent;padding:6px 8px;font-size:10px}.mail-link-open:disabled{opacity:.55;cursor:wait}
body.ep-wasteland .mail-safety-warning{background:#392719;border-color:#a8793e;color:#f0d4a3}body.ep-wasteland .mail-link-row{border-color:#4a3f33}body.ep-wasteland .mail-link-risky{background:#392719;border-color:#a8793e}body.ep-wasteland .mail-link-row span,body.ep-wasteland .mail-link-row small{color:#cbbba0}
body.ep-daylight .mail-safety-warning{background:#fff6df;color:#5b3c17}body.ep-daylight .mail-link-risky{background:#fff8ea;border-color:#d69b43}
+96
View File
@@ -6,6 +6,102 @@ let mailboxSyncQueued = false;
let mailboxRefreshPending = false;
let folderBeforeSearch = null;
const senderBrandDomains = {
amazon: ['amazon.com', 'amazon.co.uk'],
apple: ['apple.com', 'icloud.com'],
google: ['google.com', 'gmail.com'],
microsoft: ['microsoft.com', 'outlook.com', 'live.com'],
paypal: ['paypal.com']
};
function suspiciousSenderReasons(message) {
const email = String(message.email || '').trim().toLowerCase();
const domain = email.split('@').pop() || '';
if (!domain) return [];
const reasons = [];
if (domain.includes('xn--')) reasons.push('The sender address uses an internationalized domain that may imitate another domain.');
const name = String(message.sender || '').toLowerCase();
for (const [brand, domains] of Object.entries(senderBrandDomains)) {
const brandName = new RegExp(`^(?:the\\s+)?${brand}(?:\\s+(?:customer\\s+service|support|security|account|billing|team|payments?|services?))*$`, 'i');
if (brandName.test(name) && !domains.some(allowed => domain === allowed || domain.endsWith(`.${allowed}`))) {
reasons.push(`The display name mentions ${brand}, but the sender domain is ${domain}.`);
}
}
if (/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(name) && name.split('@').pop() !== domain) {
reasons.push('The address-like display name does not match the actual sender domain.');
}
return [...new Set(reasons)];
}
function inspectMailLink(raw) {
const cleaned = String(raw).replace(/[.,!?;:)\]}>"']+$/g, '');
let parsed;
try { parsed = new URL(cleaned); } catch { return null; }
if (!['http:', 'https:'].includes(parsed.protocol) || parsed.username || parsed.password) return null;
const host = parsed.hostname.toLowerCase();
const reasons = [];
if (parsed.protocol === 'http:') reasons.push('unencrypted HTTP connection');
if (host.includes('xn--')) reasons.push('internationalized domain that may imitate another address');
if (/^(?:\d{1,3}\.){3}\d{1,3}$/.test(host) || host.startsWith('[')) reasons.push('IP-address destination instead of a named website');
if (['bit.ly', 't.co', 'tinyurl.com', 'is.gd', 'lnkd.in'].includes(host)) reasons.push('shortened link hides its final destination');
for (const [brand, domains] of Object.entries(senderBrandDomains)) {
const mentionsBrand = new RegExp(`(^|[.-])${brand.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')}([.-]|$)`, 'i').test(host);
if (mentionsBrand && !domains.some(domain => host === domain || host.endsWith(`.${domain}`))) {
reasons.push(`hostname mentions ${brand} without using its usual domain`);
}
}
return { url: parsed.href, host, reasons };
}
function messageLinks(message) {
const bodyLinks = (message.body || []).join('\n').match(/https?:\/\/[^\s<>"']+/gi) || [];
const declaredLinks = Array.isArray(message.links) ? message.links : [];
return [...new Set([...bodyLinks, ...declaredLinks])]
.map(inspectMailLink)
.filter(Boolean)
.slice(0, 30);
}
const originalOpenMessage = openMessage;
openMessage = function (id) {
originalOpenMessage(id);
const message = messages.find(item => item.id === id);
if (!message) return;
const senderReasons = suspiciousSenderReasons(message);
const links = messageLinks(message);
const warnings = [];
if (senderReasons.length) {
warnings.push(`<section class="mail-safety-warning" role="alert"><strong>Sender details may be misleading</strong><ul>${senderReasons.map(reason => `<li>${esc(reason)}</li>`).join('')}</ul><small>Sender names and addresses can be forged. Verify the sender through a trusted channel.</small></section>`);
}
const linkCards = links.map((link, index) => `
<div class="mail-link-row ${link.reasons.length ? 'mail-link-risky' : ''}">
<div><strong>${link.reasons.length ? 'Potentially unsafe link' : 'External link'}</strong><span>${esc(link.host)}</span>
${link.reasons.length ? `<small>${esc(link.reasons.join('; '))}</small>` : ''}</div>
<button type="button" class="mail-link-open" data-mail-link="${index}">Review &amp; open</button>
</div>`).join('');
const reader = $('#reader-pane');
const header = reader.querySelector('.reader-header');
if (warnings.length && header) header.insertAdjacentHTML('afterend', warnings.join(''));
const replyBar = reader.querySelector('.reply-bar');
if (links.length && replyBar) {
replyBar.insertAdjacentHTML('beforebegin', `<section class="mail-links"><h3>Links in this message</h3>${links.some(link => link.reasons.length) ? '<p class="mail-safety-intro">Some links show warning signs. Every link requires confirmation before it opens.</p>' : ''}${linkCards}</section>`);
reader.querySelectorAll('[data-mail-link]').forEach(button => {
button.onclick = async () => {
const link = links[Number(button.dataset.mailLink)];
if (!link) return;
button.disabled = true;
try {
await window.daybreakMail.openExternal(link.url);
} catch (error) {
toast(error.message || 'Could not open this link');
} finally {
button.disabled = false;
}
};
});
}
};
function updateAccountCard(account) {
const card = $('#account-settings');
if (!card) return;
+1
View File
@@ -529,6 +529,7 @@
setSnooze: (details) => EpMail.setSnooze(details),
checkSnoozeReminders: () => EpMail.checkSnoozeReminders(),
saveAttachment: (details) => EpMail.saveAttachment(details),
openExternal: (url) => EpMail.openExternal({ url }),
send: (message) => EpMail.send(message),
disconnect: (id) => EpMail.removeAccount({ id }),
davList: () => EpMail.davList(),
+3
View File
@@ -121,3 +121,6 @@ body.ep-daylight .row-check:checked{accent-color:#526a2c}
.search-filters{position:absolute;right:78px;top:calc(100% + 8px);z-index:12;display:grid;grid-template-columns:1fr 1fr;gap:10px;width:min(360px,calc(100vw - 32px));padding:14px;border:1px solid var(--border,#d8ddd5);border-radius:12px;background:var(--panel,#fff);box-shadow:0 8px 28px #17201724}.search-filters.hidden{display:none}.search-filters label{display:grid;gap:4px;font-size:12px}.search-filters input,.search-filters select{min-width:0;border:1px solid var(--border,#d8ddd5);border-radius:7px;padding:7px;background:transparent;color:inherit;font:inherit}.search-filters .filter-checkbox{display:flex;align-items:center;gap:7px}.search-filters .filter-checkbox input{min-width:auto}.search-filters .text-button{grid-column:1/-1;justify-self:start}.top-actions{position:relative}
body.ep-wasteland .search-filters{background:#211c18;border-color:#4a3f33;color:#d4cbbc}body.ep-wasteland .search-filters input,body.ep-wasteland .search-filters select{border-color:#4a3f33;color:#d4cbbc}
body.ep-daylight .search-filters{background:#fbfbf6;border-color:#b9c5bc;color:#263a3d}
.mail-safety-warning{margin:10px 16px;padding:12px 14px;border:1px solid #d69b43;border-left:4px solid #b87321;border-radius:8px;background:#fff6df;color:#5b3c17;font-size:12px}.mail-safety-warning strong{display:block}.mail-safety-warning ul{margin:7px 0;padding-left:18px}.mail-safety-warning small{display:block;line-height:1.4}.mail-links{padding:12px 16px;border-top:1px solid var(--line,#eaede8)}.mail-links h3{margin:0 0 8px;font-size:12px}.mail-safety-intro{font-size:11px;color:#8d4a16}.mail-link-row{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:9px 10px;margin-top:6px;border:1px solid var(--line,#eaede8);border-radius:8px;font-size:11px}.mail-link-row>div{min-width:0;display:grid;gap:3px}.mail-link-row span,.mail-link-row small{overflow-wrap:anywhere;color:#727970}.mail-link-risky{border-color:#d69b43;background:#fff8ea}.mail-link-open{flex:none;border:1px solid #9ba99b;border-radius:6px;background:transparent;padding:6px 8px;font-size:10px}.mail-link-open:disabled{opacity:.55;cursor:wait}
body.ep-wasteland .mail-safety-warning{background:#392719;border-color:#a8793e;color:#f0d4a3}body.ep-wasteland .mail-link-row{border-color:#4a3f33}body.ep-wasteland .mail-link-risky{background:#392719;border-color:#a8793e}body.ep-wasteland .mail-link-row span,body.ep-wasteland .mail-link-row small{color:#cbbba0}
body.ep-daylight .mail-safety-warning{background:#fff6df;color:#5b3c17}body.ep-daylight .mail-link-risky{background:#fff8ea;border-color:#d69b43}