mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-01-06 14:58:19 +08:00
mailto parse improvements (Closes #427)
This commit is contained in:
parent
47cc73c992
commit
3e01887f85
1 changed files with 19 additions and 15 deletions
|
@ -143,38 +143,42 @@
|
||||||
sMailToUrl = sMailToUrl.toString().substr(7);
|
sMailToUrl = sMailToUrl.toString().substr(7);
|
||||||
|
|
||||||
var
|
var
|
||||||
|
aTo = [],
|
||||||
|
aCc = null,
|
||||||
|
aBcc = null,
|
||||||
oParams = {},
|
oParams = {},
|
||||||
oToEmailModel = null,
|
EmailModel = require('Model/Email'),
|
||||||
oCcEmailModel = null,
|
|
||||||
oBccEmailModel = null,
|
|
||||||
sEmail = sMailToUrl.replace(/\?.+$/, ''),
|
sEmail = sMailToUrl.replace(/\?.+$/, ''),
|
||||||
sQueryString = sMailToUrl.replace(/^[^\?]*\?/, ''),
|
sQueryString = sMailToUrl.replace(/^[^\?]*\?/, ''),
|
||||||
EmailModel = require('Model/Email')
|
fParseEmailLine = function (sLine) {
|
||||||
|
return sLine ? _.compact(_.map(window.decodeURIComponent(sLine).split(/[,]/), function (sItem) {
|
||||||
|
var oEmailModel = new EmailModel();
|
||||||
|
oEmailModel.mailsoParse(sItem);
|
||||||
|
return '' !== oEmailModel.email ? oEmailModel : null;
|
||||||
|
})) : null;
|
||||||
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
oToEmailModel = new EmailModel();
|
aTo = fParseEmailLine(sEmail);
|
||||||
oToEmailModel.parse(window.decodeURIComponent(sEmail));
|
|
||||||
|
|
||||||
oParams = Utils.simpleQueryParser(sQueryString);
|
oParams = Utils.simpleQueryParser(sQueryString);
|
||||||
|
|
||||||
if (!Utils.isUnd(oParams.cc))
|
if (!Utils.isUnd(oParams.cc))
|
||||||
{
|
{
|
||||||
oCcEmailModel = new EmailModel();
|
aCc = fParseEmailLine(window.decodeURIComponent(oParams.cc));
|
||||||
oCcEmailModel.parse(window.decodeURIComponent(oParams.cc));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Utils.isUnd(oParams.bcc))
|
if (!Utils.isUnd(oParams.bcc))
|
||||||
{
|
{
|
||||||
oBccEmailModel = new EmailModel();
|
aBcc = fParseEmailLine(window.decodeURIComponent(oParams.bcc));
|
||||||
oBccEmailModel.parse(window.decodeURIComponent(oParams.bcc));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
require('Knoin/Knoin').showScreenPopup(PopupComposeVoreModel, [Enums.ComposeType.Empty, null,
|
require('Knoin/Knoin').showScreenPopup(PopupComposeVoreModel, [Enums.ComposeType.Empty, null,
|
||||||
oToEmailModel && oToEmailModel.email ? [oToEmailModel] : null,
|
aTo, aCc, aBcc,
|
||||||
oCcEmailModel && oCcEmailModel.email ? [oCcEmailModel] : null,
|
Utils.isUnd(oParams.subject) ? null :
|
||||||
oBccEmailModel && oBccEmailModel.email ? [oBccEmailModel] : null,
|
Utils.pString(window.decodeURIComponent(oParams.subject)),
|
||||||
Utils.isUnd(oParams.subject) ? null : Utils.pString(oParams.subject),
|
Utils.isUnd(oParams.body) ? null :
|
||||||
Utils.isUnd(oParams.body) ? null : Utils.plainToHtml(Utils.pString(oParams.body))
|
Utils.plainToHtml(Utils.pString(window.decodeURIComponent(oParams.body)))
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in a new issue