mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-07 08:27:03 +03:00
Bugfix: domain disabled wildcard failed
This commit is contained in:
parent
df80ff9533
commit
2b3a18c629
3 changed files with 22 additions and 37 deletions
|
|
@ -160,8 +160,7 @@ class ChangePasswordPlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||||
$bResult = false;
|
$bResult = false;
|
||||||
$oConfig = $this->Config();
|
$oConfig = $this->Config();
|
||||||
foreach ($this->getSupportedDrivers() as $name => $class) {
|
foreach ($this->getSupportedDrivers() as $name => $class) {
|
||||||
$sFoundedValue = '';
|
if (\RainLoop\Plugins\Helper::ValidateWildcardValues($oAccount->Email(), $oConfig->Get('plugin', "driver_{$name}_allowed_emails"))) {
|
||||||
if (\RainLoop\Plugins\Helper::ValidateWildcardValues($oAccount->Email(), $oConfig->Get('plugin', "driver_{$name}_allowed_emails"), $sFoundedValue)) {
|
|
||||||
$name = $class::NAME;
|
$name = $class::NAME;
|
||||||
$oLogger = $oActions->Logger();
|
$oLogger = $oActions->Logger();
|
||||||
try
|
try
|
||||||
|
|
|
||||||
|
|
@ -9,45 +9,35 @@ class Helper
|
||||||
$sFoundValue = '';
|
$sFoundValue = '';
|
||||||
|
|
||||||
$sString = \trim($sString);
|
$sString = \trim($sString);
|
||||||
if ('' === $sString)
|
if ('' === $sString) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sWildcardValues = \trim($sWildcardValues);
|
$sWildcardValues = \trim($sWildcardValues);
|
||||||
if ('' === $sWildcardValues)
|
if ('' === $sWildcardValues) {
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('*' === $sWildcardValues)
|
if ('*' === $sWildcardValues) {
|
||||||
{
|
|
||||||
$sFoundValue = '*';
|
$sFoundValue = '*';
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sWildcardValues = \preg_replace('/[*]+/', '*', \preg_replace('/[\s,;]+/', ' ', $sWildcardValues));
|
$aWildcardValues = \preg_split('/[\\s,;]+/', \preg_replace('/\\*+/', '*', $sWildcardValues));
|
||||||
$aWildcardValues = \explode(' ', $sWildcardValues);
|
|
||||||
|
|
||||||
foreach ($aWildcardValues as $sItem)
|
foreach ($aWildcardValues as $sItem) {
|
||||||
{
|
if (false === \strpos($sItem, '*')) {
|
||||||
if (false === \strpos($sItem, '*'))
|
if ($sString === $sItem) {
|
||||||
{
|
|
||||||
if ($sString === $sItem)
|
|
||||||
{
|
|
||||||
$sFoundValue = $sItem;
|
$sFoundValue = $sItem;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$aItem = \explode('*', $sItem);
|
$aItem = \explode('*', $sItem);
|
||||||
$aItem = \array_map(function ($sItem) {
|
$aItem = \array_map(function ($sItem) {
|
||||||
return \preg_quote($sItem, '/');
|
return \preg_quote($sItem, '/');
|
||||||
}, $aItem);
|
}, $aItem);
|
||||||
|
|
||||||
if (\preg_match('/'.\implode('.*', $aItem).'/', $sString))
|
if (\preg_match('/'.\implode('.*', $aItem).'/', $sString)) {
|
||||||
{
|
|
||||||
$sFoundValue = $sItem;
|
$sFoundValue = $sItem;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -82,18 +82,18 @@ class DefaultDomain implements DomainInterface
|
||||||
{
|
{
|
||||||
$mResult = null;
|
$mResult = null;
|
||||||
|
|
||||||
$sDisabled = '';
|
$aDisabled = [];
|
||||||
$sFoundValue = '';
|
$sFoundValue = '';
|
||||||
|
|
||||||
$sRealFileName = $this->codeFileName($sName);
|
$sRealFileName = $this->codeFileName($sName);
|
||||||
|
|
||||||
if (\file_exists($this->sDomainPath.'/disabled'))
|
if (\file_exists($this->sDomainPath.'/disabled')) {
|
||||||
{
|
$aDisabled = \explode(',', \file_get_contents($this->sDomainPath.'/disabled'));
|
||||||
$sDisabled = \file_get_contents($this->sDomainPath.'/disabled');
|
|
||||||
}
|
}
|
||||||
|
$bCheckDisabled = $bCheckDisabled && 0 < \count($aDisabled);
|
||||||
|
|
||||||
if (\file_exists($this->sDomainPath.'/'.$sRealFileName.'.ini') &&
|
if (\file_exists($this->sDomainPath.'/'.$sRealFileName.'.ini') &&
|
||||||
(!$bCheckDisabled || 0 === \strlen($sDisabled) || false === \strpos(','.$sDisabled.',', ','.\MailSo\Base\Utils::IdnToAscii($sName, true).',')))
|
(!$bCheckDisabled || !\in_array(\MailSo\Base\Utils::IdnToAscii($sName, true), $aDisabled)))
|
||||||
{
|
{
|
||||||
$aDomain = \parse_ini_file($this->sDomainPath.'/'.$sRealFileName.'.ini') ?: array();
|
$aDomain = \parse_ini_file($this->sDomainPath.'/'.$sRealFileName.'.ini') ?: array();
|
||||||
// if ($bCheckAliases && !empty($aDomain['alias']))
|
// if ($bCheckAliases && !empty($aDomain['alias']))
|
||||||
|
|
@ -109,7 +109,7 @@ class DefaultDomain implements DomainInterface
|
||||||
$mResult = \RainLoop\Model\Domain::NewInstanceFromDomainConfigArray($sName, $aDomain);
|
$mResult = \RainLoop\Model\Domain::NewInstanceFromDomainConfigArray($sName, $aDomain);
|
||||||
}
|
}
|
||||||
else if ($bCheckAliases && \file_exists($this->sDomainPath.'/'.$sRealFileName.'.alias') &&
|
else if ($bCheckAliases && \file_exists($this->sDomainPath.'/'.$sRealFileName.'.alias') &&
|
||||||
(!$bCheckDisabled || 0 === \strlen($sDisabled) || false === \strpos(','.$sDisabled.',', ','.\MailSo\Base\Utils::IdnToAscii($sName, true).',')))
|
(!$bCheckDisabled || !\in_array(\MailSo\Base\Utils::IdnToAscii($sName, true), $aDisabled)))
|
||||||
{
|
{
|
||||||
$sAlias = \trim(\file_get_contents($this->sDomainPath.'/'.$sRealFileName.'.alias'));
|
$sAlias = \trim(\file_get_contents($this->sDomainPath.'/'.$sRealFileName.'.alias'));
|
||||||
if (!empty($sAlias))
|
if (!empty($sAlias))
|
||||||
|
|
@ -126,16 +126,12 @@ class DefaultDomain implements DomainInterface
|
||||||
else if ($bFindWithWildCard)
|
else if ($bFindWithWildCard)
|
||||||
{
|
{
|
||||||
$sNames = $this->getWildcardDomainsLine();
|
$sNames = $this->getWildcardDomainsLine();
|
||||||
if (\strlen($sNames))
|
if (\strlen($sNames)
|
||||||
{
|
&& \RainLoop\Plugins\Helper::ValidateWildcardValues(\MailSo\Base\Utils::IdnToUtf8($sName, true), $sNames, $sFoundValue)
|
||||||
if (\RainLoop\Plugins\Helper::ValidateWildcardValues(
|
&& \strlen($sFoundValue)
|
||||||
\MailSo\Base\Utils::IdnToUtf8($sName, true), $sNames, $sFoundValue) && \strlen($sFoundValue))
|
&& (!$bCheckDisabled || !\in_array($sFoundValue, $aDisabled))
|
||||||
{
|
) {
|
||||||
if (!$bCheckDisabled || 0 === \strlen($sDisabled) || false === \strpos(','.$sDisabled.',', ','.$sFoundValue.','))
|
$mResult = $this->Load($sFoundValue, false);
|
||||||
{
|
|
||||||
$mResult = $this->Load($sFoundValue, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue