mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-01 13:39:22 +03:00
Preparing to support wildcard domains.
This commit is contained in:
parent
c811fdf545
commit
126b55b2d5
4 changed files with 126 additions and 44 deletions
|
|
@ -14,11 +14,14 @@ class Helper
|
|||
/**
|
||||
* @param string $sString
|
||||
* @param string $sWildcardValues
|
||||
* @param string $sFoundedValue = ''
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
static public function ValidateWildcardValues($sString, $sWildcardValues)
|
||||
static public function ValidateWildcardValues($sString, $sWildcardValues, &$sFoundedValue = '')
|
||||
{
|
||||
$sFoundedValue = '';
|
||||
|
||||
$sString = \trim($sString);
|
||||
if ('' === $sString)
|
||||
{
|
||||
|
|
@ -26,11 +29,17 @@ class Helper
|
|||
}
|
||||
|
||||
$sWildcardValues = \trim($sWildcardValues);
|
||||
if ('' === $sWildcardValues || '*' === $sWildcardValues)
|
||||
if ('' === $sWildcardValues)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if ('*' === $sWildcardValues)
|
||||
{
|
||||
$sFoundedValue = '*';
|
||||
return true;
|
||||
}
|
||||
|
||||
$sWildcardValues = \preg_replace('/[*]+/', '*', \preg_replace('/[\s,;]+/', ' ', $sWildcardValues));
|
||||
$aWildcardValues = \explode(' ', $sWildcardValues);
|
||||
|
||||
|
|
@ -40,6 +49,7 @@ class Helper
|
|||
{
|
||||
if ($sString === $sItem)
|
||||
{
|
||||
$sFoundedValue = $sItem;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -52,6 +62,7 @@ class Helper
|
|||
|
||||
if (\preg_match('/'.\implode('.*', $aItem).'/', $sString))
|
||||
{
|
||||
$sFoundedValue = $sItem;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue