mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-07 00:17:03 +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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -902,6 +902,7 @@ class Actions
|
|||
'LoginDescription' => $oConfig->Get('branding', 'login_desc', ''),
|
||||
'LoginCss' => $oConfig->Get('branding', 'login_css', ''),
|
||||
'Token' => $oConfig->Get('security', 'csrf_protection', false) ? \RainLoop\Utils::GetCsrfToken() : '',
|
||||
'OpenPGP' => $oConfig->Get('security', 'openpgp', false),
|
||||
'InIframe' => (bool) $oConfig->Get('labs', 'in_iframe', false),
|
||||
'AllowAdminPanel' => (bool) $oConfig->Get('security', 'allow_admin_panel', true),
|
||||
'CustomLoginLink' => $oConfig->Get('labs', 'custom_login_link', ''),
|
||||
|
|
@ -1955,6 +1956,7 @@ class Actions
|
|||
$this->setConfigFromParams($oConfig, 'LoginCss', 'branding', 'login_css', 'string');
|
||||
|
||||
$this->setConfigFromParams($oConfig, 'TokenProtection', 'security', 'csrf_protection', 'bool');
|
||||
$this->setConfigFromParams($oConfig, 'OpenPGP', 'security', 'openpgp', 'bool');
|
||||
$this->setConfigFromParams($oConfig, 'EnabledPlugins', 'plugins', 'enable', 'bool');
|
||||
|
||||
$this->setConfigFromParams($oConfig, 'GoogleEnable', 'social', 'google_enable', 'bool');
|
||||
|
|
@ -6320,14 +6322,13 @@ class Actions
|
|||
}
|
||||
}
|
||||
|
||||
$sPlain = $sPlainRaw = '';
|
||||
$sPlain = '';
|
||||
$sHtml = $mResponse->Html();
|
||||
$bRtl = false;
|
||||
|
||||
if (0 === \strlen($sHtml))
|
||||
{
|
||||
$sPlain = $mResponse->Plain();
|
||||
$sPlainRaw = $mResponse->PlainRaw();
|
||||
$bRtl = \MailSo\Base\Utils::IsRTL($sPlain);
|
||||
}
|
||||
else
|
||||
|
|
@ -6341,13 +6342,15 @@ class Actions
|
|||
$mResult['Html'] = 0 === \strlen($sHtml) ? '' : \MailSo\Base\HtmlUtils::ClearHtml(
|
||||
$sHtml, $bHasExternals, $mFoundedCIDs, $aContentLocationUrls, $mFoundedContentLocationUrls);
|
||||
|
||||
$mResult['PlainRaw'] = $sPlain;
|
||||
$mResult['Plain'] = 0 === \strlen($sPlain) ? '' : \MailSo\Base\HtmlUtils::ConvertPlainToHtml($sPlain);
|
||||
$mResult['PlainRaw'] = $sPlainRaw;
|
||||
$mResult['Rtl'] = $bRtl;
|
||||
|
||||
$mResult['PgpSigned'] = $mResponse->PgpSigned();
|
||||
$mResult['PgpEncrypted'] = $mResponse->PgpEncrypted();
|
||||
$mResult['PgpSignature'] = $mResponse->PgpSignature();
|
||||
|
||||
unset($sHtml, $sPlain, $sPlainRaw);
|
||||
unset($sHtml, $sPlain);
|
||||
|
||||
$mResult['HasExternals'] = $bHasExternals;
|
||||
$mResult['HasInternals'] = (\is_array($mFoundedCIDs) && 0 < \count($mFoundedCIDs)) ||
|
||||
|
|
|
|||
|
|
@ -103,6 +103,7 @@ class Application extends \RainLoop\Config\AbstractConfig
|
|||
'Enable CSRF protection (http://en.wikipedia.org/wiki/Cross-site_request_forgery)'),
|
||||
|
||||
'custom_server_signature' => array('RainLoop'),
|
||||
'openpgp' => array(false),
|
||||
'admin_login' => array('admin', 'Login and password for web admin panel'),
|
||||
'admin_password' => array('12345'),
|
||||
'allow_admin_panel' => array(true, 'Access settings'),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue