Upgrade to 3.4.1
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Kirby\Http;
|
||||
|
||||
use Kirby\Toolkit\Str;
|
||||
use TrueBV\Punycode;
|
||||
|
||||
/**
|
||||
@@ -24,4 +25,40 @@ class Idn
|
||||
{
|
||||
return (new Punycode())->encode($domain);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes a email address to the Unicode format
|
||||
*
|
||||
* @param string $email
|
||||
* @return string
|
||||
*/
|
||||
public static function decodeEmail(string $email): string
|
||||
{
|
||||
if (Str::contains($email, 'xn--') === true) {
|
||||
$parts = Str::split($email, '@');
|
||||
$address = $parts[0];
|
||||
$domain = Idn::decode($parts[1] ?? '');
|
||||
$email = $address . '@' . $domain;
|
||||
}
|
||||
|
||||
return $email;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes a email address to the Punycode format
|
||||
*
|
||||
* @param string $email
|
||||
* @return string
|
||||
*/
|
||||
public static function encodeEmail(string $email): string
|
||||
{
|
||||
if (mb_detect_encoding($email, 'ASCII', true) === false) {
|
||||
$parts = Str::split($email, '@');
|
||||
$address = $parts[0];
|
||||
$domain = Idn::encode($parts[1] ?? '');
|
||||
$email = $address . '@' . $domain;
|
||||
}
|
||||
|
||||
return $email;
|
||||
}
|
||||
}
|
||||
|
@@ -177,19 +177,25 @@ class Remote
|
||||
];
|
||||
|
||||
// determine the TLS CA to use
|
||||
if (is_file($this->options['ca']) === true) {
|
||||
$this->curlopt[CURLOPT_SSL_VERIFYPEER] = true;
|
||||
$this->curlopt[CURLOPT_CAINFO] = $this->options['ca'];
|
||||
} elseif (is_dir($this->options['ca']) === true) {
|
||||
$this->curlopt[CURLOPT_SSL_VERIFYPEER] = true;
|
||||
$this->curlopt[CURLOPT_CAPATH] = $this->options['ca'];
|
||||
} elseif ($this->options['ca'] === self::CA_INTERNAL) {
|
||||
if ($this->options['ca'] === self::CA_INTERNAL) {
|
||||
$this->curlopt[CURLOPT_SSL_VERIFYPEER] = true;
|
||||
$this->curlopt[CURLOPT_CAINFO] = dirname(__DIR__, 2) . '/cacert.pem';
|
||||
} elseif ($this->options['ca'] === self::CA_SYSTEM) {
|
||||
$this->curlopt[CURLOPT_SSL_VERIFYPEER] = true;
|
||||
} elseif ($this->options['ca'] === false) {
|
||||
$this->curlopt[CURLOPT_SSL_VERIFYPEER] = false;
|
||||
} elseif (
|
||||
is_string($this->options['ca']) === true &&
|
||||
is_file($this->options['ca']) === true
|
||||
) {
|
||||
$this->curlopt[CURLOPT_SSL_VERIFYPEER] = true;
|
||||
$this->curlopt[CURLOPT_CAINFO] = $this->options['ca'];
|
||||
} elseif (
|
||||
is_string($this->options['ca']) === true &&
|
||||
is_dir($this->options['ca']) === true
|
||||
) {
|
||||
$this->curlopt[CURLOPT_SSL_VERIFYPEER] = true;
|
||||
$this->curlopt[CURLOPT_CAPATH] = $this->options['ca'];
|
||||
} else {
|
||||
throw new InvalidArgumentException('Invalid "ca" option for the Remote class');
|
||||
}
|
||||
|
@@ -376,7 +376,7 @@ class Request
|
||||
/**
|
||||
* Returns the Query object
|
||||
*
|
||||
* @return \Kirby\Http\Query
|
||||
* @return \Kirby\Http\Request\Query
|
||||
*/
|
||||
public function query()
|
||||
{
|
||||
|
@@ -55,6 +55,26 @@ class Query
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns `true` if the request doesn't contain query variables
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEmpty(): bool
|
||||
{
|
||||
return empty($this->data) === true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns `true` if the request contains query variables
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isNotEmpty(): bool
|
||||
{
|
||||
return empty($this->data) === false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the query data array
|
||||
* back to a query string
|
||||
|
Reference in New Issue
Block a user