mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-04 15:07:02 +03:00
mailto handler (research) (#136)
This commit is contained in:
parent
706d4408e7
commit
818bf9fb40
11 changed files with 316 additions and 206 deletions
|
|
@ -283,6 +283,26 @@ class Utils
|
|||
return !\preg_match('/[^\x09\x10\x13\x0A\x0D\x20-\x7E]/', $sValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sValue
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function StrToLowerIfAscii($sValue)
|
||||
{
|
||||
return \MailSo\Base\Utils::IsAscii($sValue) ? \strtolower($sValue) : $sValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sValue
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function StrToUpperIfAscii($sValue)
|
||||
{
|
||||
return \MailSo\Base\Utils::IsAscii($sValue) ? \strtoupper($sValue) : $sValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sValue
|
||||
*
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ class Actions
|
|||
{
|
||||
const AUTH_TOKEN_KEY = 'rlauth';
|
||||
const AUTH_SIGN_ME_TOKEN_KEY = 'rlsmauth';
|
||||
const AUTH_MAILTO_TOKEN_KEY = 'rlmailtoauth';
|
||||
const AUTH_SPEC_TOKEN_KEY = 'rlspecauth';
|
||||
const AUTH_ADMIN_TOKEN_KEY = 'rlaauth';
|
||||
const AUTH_LAST_ERROR = 'rllasterrorcode';
|
||||
|
|
@ -819,6 +820,22 @@ class Actions
|
|||
|
||||
return $bResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sTo
|
||||
*/
|
||||
public function SetMailtoRequest($sTo)
|
||||
{
|
||||
if (!empty($sTo))
|
||||
{
|
||||
\RainLoop\Utils::SetCookie(self::AUTH_MAILTO_TOKEN_KEY,
|
||||
\RainLoop\Utils::EncodeKeyValues(array(
|
||||
'Time' => microtime(true),
|
||||
'MailTo' => 'MailTo',
|
||||
'To' => $sTo
|
||||
)), 0, '/', null, null, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sEmail
|
||||
|
|
@ -932,6 +949,7 @@ class Actions
|
|||
'Auth' => false,
|
||||
'AccountHash' => '',
|
||||
'AuthAccountHash' => '',
|
||||
'MailToEmail' => '',
|
||||
'Email' => '',
|
||||
'Title' => $oConfig->Get('webmail', 'title', ''),
|
||||
'LoadingDescription' => $oConfig->Get('webmail', 'loading_description', ''),
|
||||
|
|
@ -972,6 +990,18 @@ class Actions
|
|||
$oSettings = null;
|
||||
if (!$bAdmin)
|
||||
{
|
||||
$sToken = \RainLoop\Utils::GetCookie(self::AUTH_MAILTO_TOKEN_KEY, null);
|
||||
if (null !== $sToken)
|
||||
{
|
||||
\RainLoop\Utils::ClearCookie(self::AUTH_MAILTO_TOKEN_KEY);
|
||||
$mMailToData = \RainLoop\Utils::DecodeKeyValues($sToken);
|
||||
if (\is_array($mMailToData) && !empty($mMailToData['MailTo']) && 'MailTo' === $mMailToData['MailTo'] &&
|
||||
!empty($mMailToData['To']))
|
||||
{
|
||||
$aResult['MailToEmail'] = $mMailToData['To'];
|
||||
}
|
||||
}
|
||||
|
||||
$oAccount = $this->getAccountFromToken(false);
|
||||
if ($oAccount instanceof \RainLoop\Account)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ class Service
|
|||
return $this;
|
||||
}
|
||||
|
||||
if (0 < \count($aPaths) && !empty($aPaths[0]) && !$bAdmin)
|
||||
if (0 < \count($aPaths) && !empty($aPaths[0]) && !$bAdmin && 'index' !== $aPaths[0])
|
||||
{
|
||||
$sMethodName = 'Service'.$aPaths[0];
|
||||
if (\method_exists($this->oServiceActions, $sMethodName) &&
|
||||
|
|
|
|||
|
|
@ -797,6 +797,26 @@ class ServiceActions
|
|||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function ServiceMailto()
|
||||
{
|
||||
$sTo = \trim($this->oHttp->GetQuery('to', ''));
|
||||
if (!empty($sTo))
|
||||
{
|
||||
if (preg_match('/^mailto:/i', $sTo))
|
||||
{
|
||||
$sTo = \substr($sTo, 7);
|
||||
}
|
||||
|
||||
$this->oActions->SetMailtoRequest(\MailSo\Base\Utils::StrToLowerIfAscii($sTo));
|
||||
}
|
||||
|
||||
$this->oActions->Location('./');
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue