mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-04-17 20:33:30 +02:00
[muttator] added very simple address validity check
This commit is contained in:
@@ -653,17 +653,30 @@ liberator.Mail = function () //{{{
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var mailargs = new Object();
|
var mailargs = new Object();
|
||||||
|
|
||||||
mailargs.subject = liberator.commands.getOption(res.opts, "-subject", undefined);
|
mailargs.subject = liberator.commands.getOption(res.opts, "-subject", undefined);
|
||||||
mailargs.bcc = liberator.commands.getOption(res.opts, "-bcc", undefined);
|
mailargs.bcc = liberator.commands.getOption(res.opts, "-bcc", undefined);
|
||||||
mailargs.cc = liberator.commands.getOption(res.opts, "-cc", undefined);
|
mailargs.cc = liberator.commands.getOption(res.opts, "-cc", undefined);
|
||||||
mailargs.body = liberator.commands.getOption(res.opts, "-text", undefined);
|
mailargs.body = liberator.commands.getOption(res.opts, "-text", undefined);
|
||||||
mailargs.attachments = liberator.commands.getOption(res.opts, "-attachment", []);
|
mailargs.attachments = liberator.commands.getOption(res.opts, "-attachment", []);
|
||||||
|
|
||||||
|
var addresses = [];
|
||||||
|
if (res.args)
|
||||||
|
addresses = addresses.concat(res.args);
|
||||||
|
if (mailargs.bcc)
|
||||||
|
addresses = addresses.concat(mailargs.bcc);
|
||||||
|
if (mailargs.cc)
|
||||||
|
addresses = addresses.concat(mailargs.cc);
|
||||||
|
|
||||||
|
// TODO: is there a better way to check for validity?
|
||||||
|
if (addresses.some(function(recipient) { return !(/\S@\S+\.\S/.test(recipient)); }))
|
||||||
|
{
|
||||||
|
liberator.echoerr("Exxx: Invalid e-mail address");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (res.args.length > 0)
|
if (res.args.length > 0)
|
||||||
{
|
{
|
||||||
mailargs.to = res.args.join(", ");
|
mailargs.to = res.args.join(", ");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
composeNewMail(mailargs);
|
composeNewMail(mailargs);
|
||||||
|
|||||||
Reference in New Issue
Block a user