Upgrade to 3.2.3
This commit is contained in:
@@ -843,6 +843,26 @@ class Collection extends Iterator implements Countable
|
||||
return $collection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sort arguments from a string
|
||||
*
|
||||
* @param string $sortBy
|
||||
* @return array
|
||||
*/
|
||||
public static function sortArgs(string $sortBy): array
|
||||
{
|
||||
$sortArgs = Str::split($sortBy, ' ');
|
||||
|
||||
// fill in PHP constants
|
||||
array_walk($sortArgs, function (string &$value) {
|
||||
if (Str::startsWith($value, 'SORT_') === true && defined($value) === true) {
|
||||
$value = constant($value);
|
||||
}
|
||||
});
|
||||
|
||||
return $sortArgs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts the elements by any number of fields
|
||||
*
|
||||
|
@@ -76,6 +76,11 @@ class Query
|
||||
*/
|
||||
protected function resolve(string $query)
|
||||
{
|
||||
// direct key access in arrays
|
||||
if (is_array($this->data) === true && array_key_exists($query, $this->data) === true) {
|
||||
return $this->data[$query];
|
||||
}
|
||||
|
||||
$parts = $this->parts($query);
|
||||
$data = $this->data;
|
||||
$value = null;
|
||||
|
@@ -826,7 +826,6 @@ class Str
|
||||
return $string;
|
||||
}
|
||||
|
||||
$string = trim((string)$string, $separator);
|
||||
$parts = explode($separator, $string);
|
||||
$out = [];
|
||||
|
||||
|
@@ -3,6 +3,7 @@
|
||||
namespace Kirby\Toolkit;
|
||||
|
||||
use Exception;
|
||||
use Kirby\Http\Idn;
|
||||
use Kirby\Toolkit\Str;
|
||||
use ReflectionFunction;
|
||||
use Throwable;
|
||||
@@ -270,7 +271,20 @@ V::$validators = [
|
||||
* Checks for valid email addresses
|
||||
*/
|
||||
'email' => function ($value): bool {
|
||||
return filter_var($value, FILTER_VALIDATE_EMAIL) !== false;
|
||||
if (filter_var($value, FILTER_VALIDATE_EMAIL) === false) {
|
||||
try {
|
||||
$parts = Str::split($value, '@');
|
||||
$address = $parts[0] ?? null;
|
||||
$domain = Idn::encode($parts[1] ?? '');
|
||||
$email = $address . '@' . $domain;
|
||||
} catch (Throwable $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return filter_var($email, FILTER_VALIDATE_EMAIL) !== false;
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user