mirror of
https://github.com/mjl-/mox.git
synced 2025-07-13 13:34:37 +03:00
use css white-space: pre-wrap for email addresses displayed
since email addresses can contain multiple consecutive spaces. this is a valid address: " "@localhost and this is a different valid address: " "@localhost webmail still todo
This commit is contained in:
@ -969,6 +969,8 @@ const check = async (elem, p) => {
|
||||
elem.disabled = false;
|
||||
}
|
||||
};
|
||||
// When white-space is relevant, e.g. for email addresses (e.g. " "@example.org).
|
||||
const prewrap = (...l) => dom.span(style({ whiteSpace: 'pre-wrap' }), l);
|
||||
const client = new api.Client().withOptions({ csrfHeader: 'x-mox-csrf', login: login }).withAuthToken(localStorageGet('webaccountcsrftoken') || '');
|
||||
const link = (href, anchorOpt) => dom.a(attr.href(href), attr.rel('noopener noreferrer'), anchorOpt || href);
|
||||
const crumblink = (text, path) => {
|
||||
@ -980,7 +982,7 @@ const crumblink = (text, path) => {
|
||||
const crumbs = (...l) => {
|
||||
const crumbtext = (e) => typeof e === 'string' ? e : e.text;
|
||||
document.title = l.map(e => crumbtext(e)).join(' - ');
|
||||
const crumblink = (e) => typeof e === 'string' ? e : dom.a(e.text, attr.href(e.path));
|
||||
const crumblink = (e) => typeof e === 'string' ? prewrap(e) : dom.a(e.text, attr.href(e.path));
|
||||
return [
|
||||
dom.div(style({ float: 'right' }), localStorageGet('webaccountaddress') || '(unknown)', ' ', dom.clickbutton('Logout', attr.title('Logout, invalidating this session.'), async function click(e) {
|
||||
const b = e.target;
|
||||
@ -1381,9 +1383,9 @@ const index = async () => {
|
||||
await check(fullNameFieldset, client.AccountSaveFullName(fullName.value));
|
||||
fullName.setAttribute('value', fullName.value);
|
||||
fullNameForm.reset();
|
||||
}), dom.br(), dom.h2('Addresses'), dom.ul(Object.entries(acc.Destinations || {}).length === 0 ? dom.li('(None, login disabled)') : [], Object.entries(acc.Destinations || {}).sort().map(t => dom.li(dom.a(t[0], attr.href('#destinations/' + t[0])), t[0].startsWith('@') ? ' (catchall)' : []))), dom.br(), dom.h2('Aliases/lists'), dom.table(dom.thead(dom.tr(dom.th('Alias address', attr.title('Messages sent to this address will be delivered to all members of the alias/list.')), dom.th('Subscription address', attr.title('Address subscribed to the alias/list.')), dom.th('Allowed senders', attr.title('Whether only members can send through the alias/list, or anyone.')), dom.th('Send as alias address', attr.title('If enabled, messages can be sent with the alias address in the message "From" header.')), dom.th())), (acc.Aliases || []).length === 0 ? dom.tr(dom.td(attr.colspan('5'), 'None')) : [], (acc.Aliases || []).sort((a, b) => a.Alias.LocalpartStr < b.Alias.LocalpartStr ? -1 : (domainName(a.Alias.Domain) < domainName(b.Alias.Domain) ? -1 : 1)).map(a => dom.tr(dom.td(a.Alias.LocalpartStr, '@', domainName(a.Alias.Domain)), dom.td(a.SubscriptionAddress), dom.td(a.Alias.PostPublic ? 'Anyone' : 'Members only'), dom.td(a.Alias.AllowMsgFrom ? 'Yes' : 'No'), dom.td((a.MemberAddresses || []).length === 0 ? [] :
|
||||
}), dom.br(), dom.h2('Addresses'), dom.ul(Object.entries(acc.Destinations || {}).length === 0 ? dom.li('(None, login disabled)') : [], Object.entries(acc.Destinations || {}).sort().map(t => dom.li(dom.a(prewrap(t[0]), attr.href('#destinations/' + encodeURIComponent(t[0]))), t[0].startsWith('@') ? ' (catchall)' : []))), dom.br(), dom.h2('Aliases/lists'), dom.table(dom.thead(dom.tr(dom.th('Alias address', attr.title('Messages sent to this address will be delivered to all members of the alias/list.')), dom.th('Subscription address', attr.title('Address subscribed to the alias/list.')), dom.th('Allowed senders', attr.title('Whether only members can send through the alias/list, or anyone.')), dom.th('Send as alias address', attr.title('If enabled, messages can be sent with the alias address in the message "From" header.')), dom.th())), (acc.Aliases || []).length === 0 ? dom.tr(dom.td(attr.colspan('5'), 'None')) : [], (acc.Aliases || []).sort((a, b) => a.Alias.LocalpartStr < b.Alias.LocalpartStr ? -1 : (domainName(a.Alias.Domain) < domainName(b.Alias.Domain) ? -1 : 1)).map(a => dom.tr(dom.td(prewrap(a.Alias.LocalpartStr, '@', domainName(a.Alias.Domain))), dom.td(prewrap(a.SubscriptionAddress)), dom.td(a.Alias.PostPublic ? 'Anyone' : 'Members only'), dom.td(a.Alias.AllowMsgFrom ? 'Yes' : 'No'), dom.td((a.MemberAddresses || []).length === 0 ? [] :
|
||||
dom.clickbutton('Show members', function click() {
|
||||
popup(dom.h1('Members of alias ', a.Alias.LocalpartStr, '@', domainName(a.Alias.Domain)), dom.ul((a.MemberAddresses || []).map(addr => dom.li(addr))));
|
||||
popup(dom.h1('Members of alias ', prewrap(a.Alias.LocalpartStr, '@', domainName(a.Alias.Domain))), dom.ul((a.MemberAddresses || []).map(addr => dom.li(prewrap(addr)))));
|
||||
}))))), dom.br(), dom.h2('Change password'), passwordForm = dom.form(passwordFieldset = dom.fieldset(dom.label(style({ display: 'inline-block' }), 'New password', dom.br(), password1 = dom.input(attr.type('password'), attr.autocomplete('new-password'), attr.required(''), function focus() {
|
||||
passwordHint.style.display = '';
|
||||
})), ' ', dom.label(style({ display: 'inline-block' }), 'New password repeat', dom.br(), password2 = dom.input(attr.type('password'), attr.autocomplete('new-password'), attr.required(''))), ' ', dom.submitbutton('Change password')), passwordHint = dom.div(style({ display: 'none', marginTop: '.5ex' }), dom.clickbutton('Generate random password', function click(e) {
|
||||
@ -1481,7 +1483,7 @@ const index = async () => {
|
||||
e.stopPropagation();
|
||||
await check(e.target, client.SuppressionAdd(suppressionAddress.value, true, suppressionReason.value));
|
||||
window.location.reload(); // todo: reload less
|
||||
}), dom.table(dom.thead(dom.tr(dom.th('Address', attr.title('Address that caused this entry to be added to the list. The title (shown on hover) displays an address with a fictional simplified localpart, with lower-cased, dots removed, only first part before "+" or "-" (typicaly catchall separators). When checking if an address is on the suppression list, it is checked against this address.')), dom.th('Manual', attr.title('Whether suppression was added manually, instead of automatically based on bounces.')), dom.th('Reason'), dom.th('Since'), dom.th('Action'))), dom.tbody((suppressions || []).length === 0 ? dom.tr(dom.td(attr.colspan('5'), '(None)')) : [], (suppressions || []).map(s => dom.tr(dom.td(s.OriginalAddress, attr.title(s.BaseAddress)), dom.td(s.Manual ? '✓' : ''), dom.td(s.Reason), dom.td(age(s.Created)), dom.td(dom.clickbutton('Remove', async function click(e) {
|
||||
}), dom.table(dom.thead(dom.tr(dom.th('Address', attr.title('Address that caused this entry to be added to the list. The title (shown on hover) displays an address with a fictional simplified localpart, with lower-cased, dots removed, only first part before "+" or "-" (typicaly catchall separators). When checking if an address is on the suppression list, it is checked against this address.')), dom.th('Manual', attr.title('Whether suppression was added manually, instead of automatically based on bounces.')), dom.th('Reason'), dom.th('Since'), dom.th('Action'))), dom.tbody((suppressions || []).length === 0 ? dom.tr(dom.td(attr.colspan('5'), '(None)')) : [], (suppressions || []).map(s => dom.tr(dom.td(prewrap(s.OriginalAddress), attr.title(s.BaseAddress)), dom.td(s.Manual ? '✓' : ''), dom.td(s.Reason), dom.td(age(s.Created)), dom.td(dom.clickbutton('Remove', async function click(e) {
|
||||
await check(e.target, client.SuppressionRemove(s.OriginalAddress));
|
||||
window.location.reload(); // todo: reload less
|
||||
}))))), dom.tfoot(dom.tr(dom.td(suppressionAddress = dom.input(attr.type('required'), attr.form('suppressionAdd'))), dom.td(), dom.td(suppressionReason = dom.input(style({ width: '100%' }), attr.form('suppressionAdd'))), dom.td(), dom.td(dom.submitbutton('Add suppression', attr.form('suppressionAdd')))))), dom.br(), dom.h2('Export'), dom.p('Export all messages in all mailboxes.'), dom.form(attr.target('_blank'), attr.method('POST'), attr.action('export'), dom.input(attr.type('hidden'), attr.name('csrf'), attr.value(localStorageGet('webaccountcsrftoken') || '')), dom.input(attr.type('hidden'), attr.name('mailbox'), attr.value('')), dom.input(attr.type('hidden'), attr.name('recursive'), attr.value('on')), dom.div(style({ display: 'flex', flexDirection: 'column', gap: '.5ex' }), dom.div(dom.label(dom.input(attr.type('radio'), attr.name('format'), attr.value('maildir'), attr.checked('')), ' Maildir'), ' ', dom.label(dom.input(attr.type('radio'), attr.name('format'), attr.value('mbox')), ' Mbox')), dom.div(dom.label(dom.input(attr.type('radio'), attr.name('archive'), attr.value('tar')), ' Tar'), ' ', dom.label(dom.input(attr.type('radio'), attr.name('archive'), attr.value('tgz'), attr.checked('')), ' Tgz'), ' ', dom.label(dom.input(attr.type('radio'), attr.name('archive'), attr.value('zip')), ' Zip'), ' '), dom.div(style({ marginTop: '1ex' }), dom.submitbutton('Export')))), dom.br(), dom.h2('Import'), dom.p('Import messages from a .zip or .tgz file with maildirs and/or mbox files.'), importForm = dom.form(async function submit(e) {
|
||||
|
@ -154,6 +154,9 @@ const check = async <T>(elem: {disabled: boolean}, p: Promise<T>): Promise<T> =>
|
||||
}
|
||||
}
|
||||
|
||||
// When white-space is relevant, e.g. for email addresses (e.g. " "@example.org).
|
||||
const prewrap = (...l: string[]) => dom.span(style({whiteSpace: 'pre-wrap'}), l)
|
||||
|
||||
const client = new api.Client().withOptions({csrfHeader: 'x-mox-csrf', login: login}).withAuthToken(localStorageGet('webaccountcsrftoken') || '')
|
||||
|
||||
const link = (href: string, anchorOpt: string) => dom.a(attr.href(href), attr.rel('noopener noreferrer'), anchorOpt || href)
|
||||
@ -169,7 +172,7 @@ const crumbs = (...l: ({text: string, path: string} | string)[]) => {
|
||||
document.title = l.map(e => crumbtext(e)).join(' - ')
|
||||
|
||||
const crumblink = (e: {text: string, path: string} | string) =>
|
||||
typeof e === 'string' ? e : dom.a(e.text, attr.href(e.path))
|
||||
typeof e === 'string' ? prewrap(e) : dom.a(e.text, attr.href(e.path))
|
||||
return [
|
||||
dom.div(
|
||||
style({float: 'right'}),
|
||||
@ -758,7 +761,7 @@ const index = async () => {
|
||||
Object.entries(acc.Destinations || {}).length === 0 ? dom.li('(None, login disabled)') : [],
|
||||
Object.entries(acc.Destinations || {}).sort().map(t =>
|
||||
dom.li(
|
||||
dom.a(t[0], attr.href('#destinations/'+t[0])),
|
||||
dom.a(prewrap(t[0]), attr.href('#destinations/'+encodeURIComponent(t[0]))),
|
||||
t[0].startsWith('@') ? ' (catchall)' : [],
|
||||
),
|
||||
),
|
||||
@ -779,17 +782,17 @@ const index = async () => {
|
||||
(acc.Aliases || []).length === 0 ? dom.tr(dom.td(attr.colspan('5'), 'None')) : [],
|
||||
(acc.Aliases || []).sort((a, b) => a.Alias.LocalpartStr < b.Alias.LocalpartStr ? -1 : (domainName(a.Alias.Domain) < domainName(b.Alias.Domain) ? -1 : 1)).map(a =>
|
||||
dom.tr(
|
||||
dom.td(a.Alias.LocalpartStr, '@', domainName(a.Alias.Domain)),
|
||||
dom.td(a.SubscriptionAddress),
|
||||
dom.td(prewrap(a.Alias.LocalpartStr, '@', domainName(a.Alias.Domain))),
|
||||
dom.td(prewrap(a.SubscriptionAddress)),
|
||||
dom.td(a.Alias.PostPublic ? 'Anyone' : 'Members only'),
|
||||
dom.td(a.Alias.AllowMsgFrom ? 'Yes' : 'No'),
|
||||
dom.td(
|
||||
(a.MemberAddresses || []).length === 0 ? [] :
|
||||
dom.clickbutton('Show members', function click() {
|
||||
popup(
|
||||
dom.h1('Members of alias ', a.Alias.LocalpartStr, '@', domainName(a.Alias.Domain)),
|
||||
dom.h1('Members of alias ', prewrap(a.Alias.LocalpartStr, '@', domainName(a.Alias.Domain))),
|
||||
dom.ul(
|
||||
(a.MemberAddresses || []).map(addr => dom.li(addr)),
|
||||
(a.MemberAddresses || []).map(addr => dom.li(prewrap(addr))),
|
||||
),
|
||||
)
|
||||
}),
|
||||
@ -1148,7 +1151,7 @@ const index = async () => {
|
||||
(suppressions || []).length === 0 ? dom.tr(dom.td(attr.colspan('5'), '(None)')) : [],
|
||||
(suppressions || []).map(s =>
|
||||
dom.tr(
|
||||
dom.td(s.OriginalAddress, attr.title(s.BaseAddress)),
|
||||
dom.td(prewrap(s.OriginalAddress), attr.title(s.BaseAddress)),
|
||||
dom.td(s.Manual ? '✓' : ''),
|
||||
dom.td(s.Reason),
|
||||
dom.td(age(s.Created)),
|
||||
|
Reference in New Issue
Block a user