mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-11 00:14:50 +03:00
#89 added send OpenPGP.js signed HTML message
This commit is contained in:
parent
0cf63dab76
commit
051e78df51
3 changed files with 33 additions and 9 deletions
|
|
@ -94,6 +94,7 @@
|
|||
td:first-child {
|
||||
padding: 0 10px 0 0;
|
||||
text-align: right;
|
||||
white-space: nowrap;
|
||||
width: 4em;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -407,18 +407,15 @@ class ComposePopupView extends AbstractViewPopup {
|
|||
params.Encrypted = draft
|
||||
? await this.mailvelope.createDraft()
|
||||
: await this.mailvelope.encrypt(recipients);
|
||||
} else if (encrypt) {
|
||||
if ('openpgp' != encrypt) {
|
||||
throw 'Encryption with ' + encrypt + ' not yet implemented';
|
||||
}
|
||||
if (sign && 'openpgp' != sign[0]) {
|
||||
throw 'Signing with ' + sign[0] + ' not yet implemented';
|
||||
}
|
||||
} else if (encrypt || sign) {
|
||||
let data = new MimePart;
|
||||
data.headers['Content-Type'] = 'text/'+(TextIsHtml?'html':'plain')+'; charset="utf-8"';
|
||||
data.headers['Content-Transfer-Encoding'] = 'base64';
|
||||
data.body = base64_encode(Text);
|
||||
if (TextIsHtml && sign && sign[1]) {
|
||||
if (sign && sign[1]) {
|
||||
if ('openpgp' != sign[0]) {
|
||||
throw 'Signing with ' + sign[0] + ' not yet implemented';
|
||||
}
|
||||
let signed = new MimePart;
|
||||
signed.headers['Content-Type'] =
|
||||
'multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"';
|
||||
|
|
@ -431,7 +428,14 @@ class ComposePopupView extends AbstractViewPopup {
|
|||
signed.children.push(signature);
|
||||
data = signed;
|
||||
}
|
||||
params.Encrypted = await OpenPGPUserStore.encrypt(data.toString(), recipients);
|
||||
if (encrypt) {
|
||||
if ('openpgp' != encrypt) {
|
||||
throw 'Encryption with ' + encrypt + ' not yet implemented';
|
||||
}
|
||||
params.Encrypted = await OpenPGPUserStore.encrypt(data.toString(), recipients);
|
||||
} else {
|
||||
params.Signed = data.toString();
|
||||
}
|
||||
} else {
|
||||
params.Html = TextIsHtml ? Text : '';
|
||||
params.Text = TextIsHtml ? '' : Text;
|
||||
|
|
|
|||
|
|
@ -1104,6 +1104,7 @@ trait Messages
|
|||
$aFoundCids = array();
|
||||
$aFoundDataURL = array();
|
||||
$aFoundContentLocationUrls = array();
|
||||
$oPart;
|
||||
|
||||
if ($sHtml = $this->GetActionParam('Html', '')) {
|
||||
$oPart = new MimePart;
|
||||
|
|
@ -1142,6 +1143,23 @@ trait Messages
|
|||
unset($sHtml);
|
||||
unset($sPlain);
|
||||
|
||||
} else if ($sSigned = $this->GetActionParam('Signed', '')) {
|
||||
$aSigned = \explode("\r\n\r\n", $sSigned, 2);
|
||||
$sBoundary = \preg_replace('/^.+boundary="([^"]+)".+$/Dsi', '$1', $aSigned[0]);
|
||||
|
||||
$oPart = new MimePart;
|
||||
$oPart->Headers->AddByName(
|
||||
\MailSo\Mime\Enumerations\Header::CONTENT_TYPE,
|
||||
'multipart/signed; ' . (new \MailSo\Mime\ParameterCollection)->Add(
|
||||
new \MailSo\Mime\Parameter(\MailSo\Mime\Enumerations\Parameter::BOUNDARY, $sBoundary)
|
||||
)->ToString() . '; protocol="application/pgp-signature"'
|
||||
);
|
||||
$oPart->Body = \str_replace("--{$sBoundary}--", '', $aSigned[1]);
|
||||
$oMessage->SubParts->append($oPart);
|
||||
|
||||
unset($oAlternativePart);
|
||||
unset($sSigned);
|
||||
|
||||
} else if ($sEncrypted = $this->GetActionParam('Encrypted', '')) {
|
||||
$oPart = new MimePart;
|
||||
$oPart->Headers->AddByName(
|
||||
|
|
@ -1207,6 +1225,7 @@ trait Messages
|
|||
unset($sSignature);
|
||||
unset($sPlain);
|
||||
}
|
||||
unset($oPart);
|
||||
|
||||
$aAttachments = $this->GetActionParam('Attachments', null);
|
||||
if (\is_array($aAttachments))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue