Upgrade to 3.2.3

This commit is contained in:
Bastian Allgeier
2019-08-06 10:24:12 +02:00
parent 40f095f5de
commit 02be32bb75
48 changed files with 356 additions and 114 deletions

View File

@@ -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
*

View File

@@ -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;

View File

@@ -826,7 +826,6 @@ class Str
return $string;
}
$string = trim((string)$string, $separator);
$parts = explode($separator, $string);
$out = [];

View File

@@ -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;
},
/**