mirror of
https://github.com/mjl-/mox.git
synced 2025-07-10 09:54:40 +03:00
webmail: implement registering and handling "mailto:" links
to start composing a message. the help popup now has a button to register the "mailto:" links with the mox webmail (typically only works over https, not all browsers support it). the mailto links are specified in 6068. we support the to/cc/bcc/subject/body parameters. other parameters should be seen as custom headers, but we don't support messages with custom headers at all at the moment, so we ignore them. we now also turn text of the form "mailto:user@host" into a clickable link (will not be too common). we could be recognizing any "x@x.x" as email address and make them clickable in the future. thanks to Hans-Jörg for explaining this functionality.
This commit is contained in:
@ -576,6 +576,14 @@ var api;
|
||||
const params = [messageAddressee];
|
||||
return await _sherpaCall(this.baseURL, this.authState, { ...this.options }, paramTypes, returnTypes, fn, params);
|
||||
}
|
||||
// DecodeMIMEWords decodes Q/B-encoded words for a mime headers into UTF-8 text.
|
||||
async DecodeMIMEWords(text) {
|
||||
const fn = "DecodeMIMEWords";
|
||||
const paramTypes = [["string"]];
|
||||
const returnTypes = [["string"]];
|
||||
const params = [text];
|
||||
return await _sherpaCall(this.baseURL, this.authState, { ...this.options }, paramTypes, returnTypes, fn, params);
|
||||
}
|
||||
// SSETypes exists to ensure the generated API contains the types, for use in SSE events.
|
||||
async SSETypes() {
|
||||
const fn = "SSETypes";
|
||||
@ -961,7 +969,7 @@ const join = (l, efn) => {
|
||||
// interpunction moved to the next string instead.
|
||||
const addLinks = (text) => {
|
||||
// todo: look at ../rfc/3986 and fix up regexp. we should probably accept utf-8.
|
||||
const re = RegExp('(http|https):\/\/([:%0-9a-zA-Z._~!$&\'/()*+,;=-]+@)?([\\[\\]0-9a-zA-Z.-]+)(:[0-9]+)?([:@%0-9a-zA-Z._~!$&\'/()*+,;=-]*)(\\?[:@%0-9a-zA-Z._~!$&\'/()*+,;=?-]*)?(#[:@%0-9a-zA-Z._~!$&\'/()*+,;=?-]*)?');
|
||||
const re = RegExp('(?:(http|https):\/\/|mailto:)([:%0-9a-zA-Z._~!$&\'/()*+,;=-]+@)?([\\[\\]0-9a-zA-Z.-]+)(:[0-9]+)?([:@%0-9a-zA-Z._~!$&\'/()*+,;=-]*)(\\?[:@%0-9a-zA-Z._~!$&\'/()*+,;=?-]*)?(#[:@%0-9a-zA-Z._~!$&\'/()*+,;=?-]*)?');
|
||||
const r = [];
|
||||
while (text.length > 0) {
|
||||
const l = re.exec(text);
|
||||
@ -985,7 +993,7 @@ const addLinks = (text) => {
|
||||
url = url.substring(0, url.length - 1);
|
||||
}
|
||||
}
|
||||
r.push(dom.a(url, attr.href(url), attr.target('_blank'), attr.rel('noopener noreferrer')));
|
||||
r.push(dom.a(url, attr.href(url), url.startsWith('mailto:') ? [] : [attr.target('_blank'), attr.rel('noopener noreferrer')]));
|
||||
}
|
||||
return r;
|
||||
};
|
||||
|
Reference in New Issue
Block a user