mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-25 10:09:20 +03:00
OpenPGP - part 2 - unstable (#53)
This commit is contained in:
parent
d181974127
commit
0bb69d4494
23 changed files with 600 additions and 339 deletions
|
|
@ -103,11 +103,6 @@ class Message
|
|||
*/
|
||||
private $sPlain;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $sPlainRaw;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
|
|
@ -168,6 +163,16 @@ class Message
|
|||
*/
|
||||
private $sPgpSignature;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $bPgpSigned;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $bPgpEncrypted;
|
||||
|
||||
/**
|
||||
* @access private
|
||||
*/
|
||||
|
|
@ -201,7 +206,6 @@ class Message
|
|||
$this->oBcc = null;
|
||||
|
||||
$this->sPlain = '';
|
||||
$this->sPlainRaw = '';
|
||||
$this->sHtml = '';
|
||||
|
||||
$this->oAttachments = null;
|
||||
|
|
@ -220,6 +224,8 @@ class Message
|
|||
$this->iParentThread = 0;
|
||||
|
||||
$this->sPgpSignature = '';
|
||||
$this->bPgpSigned = false;
|
||||
$this->bPgpEncrypted = false;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -240,14 +246,6 @@ class Message
|
|||
return $this->sPlain;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function PlainRaw()
|
||||
{
|
||||
return $this->sPlainRaw;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
|
|
@ -264,6 +262,22 @@ class Message
|
|||
return $this->sPgpSignature;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function PgpSigned()
|
||||
{
|
||||
return $this->bPgpSigned;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function PgpEncrypted()
|
||||
{
|
||||
return $this->bPgpEncrypted;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sHtml
|
||||
*
|
||||
|
|
@ -776,24 +790,20 @@ class Message
|
|||
}
|
||||
else
|
||||
{
|
||||
$this->sPlain = \implode("\n", $sPlainParts);
|
||||
$this->sPlainRaw = $this->sPlain;
|
||||
$this->sPlain = \trim(\implode("\n", $sPlainParts));
|
||||
}
|
||||
|
||||
$aMatch = array();
|
||||
if (\preg_match('/-----BEGIN PGP SIGNATURE-----(.+)-----END PGP SIGNATURE-----/ism', $this->sPlain, $aMatch) && !empty($aMatch[0]))
|
||||
{
|
||||
$this->sPgpSignature = $aMatch[0];
|
||||
$this->sPlain = \trim($this->sPlain);
|
||||
$this->sPgpSignature = \trim($aMatch[0]);
|
||||
$this->bPgpSigned = true;
|
||||
}
|
||||
|
||||
$aMatch = array();
|
||||
if (!empty($this->sPgpSignature) &&
|
||||
\preg_match('/-----BEGIN PGP SIGNED MESSAGE-----(.+)-----BEGIN PGP SIGNATURE-----(.+)-----END PGP SIGNATURE-----/ism', $this->sPlain, $aMatch) &&
|
||||
!empty($aMatch[0]) && isset($aMatch[1]))
|
||||
if (\preg_match('/-----BEGIN PGP MESSAGE-----/ism', $this->sPlain, $aMatch) && !empty($aMatch[0]))
|
||||
{
|
||||
$this->sPlain = \str_replace($aMatch[0], $aMatch[1], $this->sPlain);
|
||||
$this->sPlain = \trim(\preg_replace('/^Hash: [^\s]+/i', '', \trim($this->sPlain)));
|
||||
$this->bPgpEncrypted = true;
|
||||
}
|
||||
|
||||
unset($sHtmlParts, $sPlainParts, $aMatch);
|
||||
|
|
@ -812,6 +822,7 @@ class Message
|
|||
if (\is_string($sPgpSignatureText) && 0 < \strlen($sPgpSignatureText) && 0 < \strpos($sPgpSignatureText, 'BEGIN PGP SIGNATURE'))
|
||||
{
|
||||
$this->sPgpSignature = \trim($sPgpSignatureText);
|
||||
$this->bPgpSigned = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue