Merge branch 'the-djmaze:master' into master

This commit is contained in:
cm-schl 2024-05-09 16:33:48 +02:00 committed by GitHub
commit 1f5613b504
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 17 additions and 16 deletions

View file

@ -37,7 +37,7 @@ abstract class DateTimeHelper
{
$sDateTime = \trim($sDateTime);
if (empty($sDateTime)) {
\SnappyMail\Log::info("No RFC 2822 date to parse");
\SnappyMail\Log::info('', "No RFC 2822 date to parse");
return 0;
}
@ -45,7 +45,7 @@ abstract class DateTimeHelper
$oDateTime = \DateTime::createFromFormat(\DateTime::RFC2822, $sDateTime, static::GetUtcTimeZoneObject());
// 398045302 is 1982-08-13 00:08:22 the date RFC 822 was created
if (!$oDateTime || 398045302 > $oDateTime->getTimestamp()) {
\SnappyMail\Log::notice("Failed to parse RFC 2822 date '{$sDateTime}'");
\SnappyMail\Log::notice('', "Failed to parse RFC 2822 date '{$sDateTime}'");
}
return $oDateTime ? $oDateTime->getTimestamp() : 0;
}

View file

@ -206,17 +206,15 @@ class Logger extends \SplFixedArray
}
}
public function signalHandler($signo)
public function signalHandler($signo, /*?array*/$siginfo = null)
{
if (\SIGTERM == $signo) {
exit;
}
if ($this->bUsed) {
foreach (static::$SIGNALS as $SIGNAL) {
if (\defined($SIGNAL) && \constant($SIGNAL) == $signo) {
$this->Write("Caught {$SIGNAL}");
break;
}
foreach (static::$SIGNALS as $SIGNAL) {
if (\defined($SIGNAL) && \constant($SIGNAL) == $signo) {
$this->Write("Caught {$SIGNAL} ".($siginfo ? \json_encode($siginfo) : ''), \LOG_CRIT, 'PHP');
break;
}
}
}

View file

@ -341,11 +341,14 @@ trait UserAuth
\SnappyMail\Log::notice(self::AUTH_SIGN_ME_TOKEN_KEY, 'decrypt');
$aResult = \SnappyMail\Crypt::DecryptUrlSafe($sSignMeToken, 'signme');
if (isset($aResult['e'], $aResult['u']) && \SnappyMail\UUID::isValid($aResult['u'])) {
if (!isset($aResult['c'])) {
$aTokenData['c'] = \array_key_last($aTokenData);
$aTokenData['d'] = \end($aTokenData);
}
return $aResult;
}
\SnappyMail\Log::notice(self::AUTH_SIGN_ME_TOKEN_KEY, 'invalid');
// Don't clear due to login checkbox
// Cookies::clear(self::AUTH_SIGN_ME_TOKEN_KEY);
Cookies::clear(self::AUTH_SIGN_ME_TOKEN_KEY);
}
return null;
}
@ -360,7 +363,8 @@ trait UserAuth
\SnappyMail\Crypt::EncryptUrlSafe([
'e' => $oAccount->Email(),
'u' => $uuid,
$data[0] => \base64_encode($data[1])
'c' => $data[0],
'd' => \base64_encode($data[1])
], 'signme'),
\time() + 3600 * 24 * 30 // 30 days
);
@ -382,8 +386,8 @@ trait UserAuth
throw new \RuntimeException("server token not found for {$aTokenData['e']}/.sign_me/{$aTokenData['u']}");
}
$aAccountHash = \SnappyMail\Crypt::Decrypt([
\array_key_last($aTokenData),
\base64_decode(\end($aTokenData)),
$aTokenData['c'],
\base64_decode($aTokenData['d']),
$sAuthToken
], 'signme');
if (!\is_array($aAccountHash)) {
@ -401,8 +405,7 @@ trait UserAuth
catch (\Throwable $oException)
{
\SnappyMail\Log::warning(self::AUTH_SIGN_ME_TOKEN_KEY, $oException->getMessage());
// Don't clear due to smctoken cookie missing at initialization and login checkbox
// $this->ClearSignMeData();
$this->ClearSignMeData();
}
}
return null;