This commit is contained in:
the-djmaze 2024-02-12 01:26:56 +01:00
parent 7da5692865
commit 355f6158be
3 changed files with 16 additions and 6 deletions

View file

@ -1474,7 +1474,7 @@ export class ComposePopupView extends AbstractViewPopup {
: await this.mailvelope.encrypt(recipients);
/*
Object.entries(PgpUserStore.getPublicKeyOfEmails(recipients) || {}).forEach(([k,v]) =>
params.autocrypt.push({addr:k, keydata:v.replace(/-----(BEGIN|END) PGP PUBLIC KEY BLOCK-----/).trim()})
params.autocrypt.push({addr:k, keydata:v.replace(/-----(BEGIN|END) PGP PUBLIC KEY BLOCK-----/g).trim()})
);
*/
} else if (sign || encrypt) {
@ -1525,7 +1525,7 @@ export class ComposePopupView extends AbstractViewPopup {
}
if (encrypt) {
Object.entries(PgpUserStore.getPublicKeyOfEmails(recipients) || {}).forEach(([k,v]) =>
params.autocrypt.push({addr:k, keydata:v.replace(/-----(BEGIN|END) PGP PUBLIC KEY BLOCK-----/).trim()})
params.autocrypt.push({addr:k, keydata:v.replace(/-----(BEGIN|END) PGP PUBLIC KEY BLOCK-----/g, '').trim()})
);
if ('openpgp' == encrypt) {
// Doesn't encrypt attachments

View file

@ -157,6 +157,12 @@ class Message extends Part
return $this;
}
public function SetAutocrypt(array $aValue) : self
{
$this->aHeadersValue['Autocrypt'] = $aValue;
return $this;
}
public function SetSubject(string $sSubject) : self
{
$this->aHeadersValue[Enumerations\Header::SUBJECT] = $sSubject;
@ -415,7 +421,11 @@ class Message extends Part
}
foreach ($this->aHeadersValue as $sName => $mValue) {
if (!($bWithoutBcc && \strtolower(Enumerations\Header::BCC) === \strtolower($sName))) {
if ('autocrypt' === \strtolower($sName)) {
foreach ($mValue as $key) {
$oRootPart->Headers->AddByName($sName, $key);
}
} else if (!($bWithoutBcc && \strtolower(Enumerations\Header::BCC) === \strtolower($sName))) {
$oRootPart->Headers->SetByName($sName, (string) $mValue);
}
}

View file

@ -1035,9 +1035,9 @@ trait Messages
$oMessage->SetReferences($this->GetActionParam('references', ''));
$aAutocrypt = $this->GetActionParam('autocrypt', []);
foreach ($aAutocrypt as $header) {
$oMessage->SetCustomHeader('Autocrypt', "addr={$header['addr']}; keydata={$header['keydata']}");
}
$oMessage->SetAutocrypt(
\array_map(fn($header)=>"addr={$header['addr']}; keydata={$header['keydata']}", $aAutocrypt)
);
$aFoundCids = array();
$aFoundDataURL = array();