plugin updates
This commit is contained in:
@@ -301,9 +301,10 @@ class Client
|
||||
* The authorization endpoint allows the user to first
|
||||
* authenticate, and then grant/deny the access request.
|
||||
* @param string|array $scope The scope is expressed as an array or list of space-delimited strings.
|
||||
* @param array $queryParams Querystring params to add to the authorization URL.
|
||||
* @return string
|
||||
*/
|
||||
public function createAuthUrl($scope = null)
|
||||
public function createAuthUrl($scope = null, array $queryParams = [])
|
||||
{
|
||||
if (empty($scope)) {
|
||||
$scope = $this->prepareScopes();
|
||||
@@ -315,7 +316,7 @@ class Client
|
||||
$approvalPrompt = $this->config['prompt'] ? null : $this->config['approval_prompt'];
|
||||
// include_granted_scopes should be string "true", string "false", or null
|
||||
$includeGrantedScopes = $this->config['include_granted_scopes'] === null ? null : \var_export($this->config['include_granted_scopes'], \true);
|
||||
$params = \array_filter(['access_type' => $this->config['access_type'], 'approval_prompt' => $approvalPrompt, 'hd' => $this->config['hd'], 'include_granted_scopes' => $includeGrantedScopes, 'login_hint' => $this->config['login_hint'], 'openid.realm' => $this->config['openid.realm'], 'prompt' => $this->config['prompt'], 'redirect_uri' => $this->config['redirect_uri'], 'response_type' => 'code', 'scope' => $scope, 'state' => $this->config['state']]);
|
||||
$params = \array_filter(['access_type' => $this->config['access_type'], 'approval_prompt' => $approvalPrompt, 'hd' => $this->config['hd'], 'include_granted_scopes' => $includeGrantedScopes, 'login_hint' => $this->config['login_hint'], 'openid.realm' => $this->config['openid.realm'], 'prompt' => $this->config['prompt'], 'redirect_uri' => $this->config['redirect_uri'], 'response_type' => 'code', 'scope' => $scope, 'state' => $this->config['state']]) + $queryParams;
|
||||
// If the list of scopes contains plus.login, add request_visible_actions
|
||||
// to auth URL.
|
||||
$rva = $this->config['request_visible_actions'];
|
||||
|
||||
@@ -109,7 +109,7 @@ class Client implements \WPMailSMTP\Vendor\GuzzleHttp\ClientInterface, \WPMailSM
|
||||
/**
|
||||
* The HttpClient PSR (PSR-18) specify this method.
|
||||
*
|
||||
* @inheritDoc
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function sendRequest(\WPMailSMTP\Vendor\Psr\Http\Message\RequestInterface $request) : \WPMailSMTP\Vendor\Psr\Http\Message\ResponseInterface
|
||||
{
|
||||
@@ -178,7 +178,7 @@ class Client implements \WPMailSMTP\Vendor\GuzzleHttp\ClientInterface, \WPMailSM
|
||||
*
|
||||
* @deprecated Client::getConfig will be removed in guzzlehttp/guzzle:8.0.
|
||||
*/
|
||||
public function getConfig(?string $option = null)
|
||||
public function getConfig(string $option = null)
|
||||
{
|
||||
return $option === null ? $this->config : $this->config[$option] ?? null;
|
||||
}
|
||||
@@ -367,6 +367,9 @@ class Client implements \WPMailSMTP\Vendor\GuzzleHttp\ClientInterface, \WPMailSM
|
||||
throw new \WPMailSMTP\Vendor\GuzzleHttp\Exception\InvalidArgumentException('sink must not be a boolean');
|
||||
}
|
||||
}
|
||||
if (isset($options['version'])) {
|
||||
$modify['version'] = $options['version'];
|
||||
}
|
||||
$request = \WPMailSMTP\Vendor\GuzzleHttp\Psr7\Utils::modifyRequest($request, $modify);
|
||||
if ($request->getBody() instanceof \WPMailSMTP\Vendor\GuzzleHttp\Psr7\MultipartStream) {
|
||||
// Use a multipart/form-data POST if a Content-Type is not set.
|
||||
|
||||
@@ -74,5 +74,5 @@ interface ClientInterface
|
||||
*
|
||||
* @deprecated ClientInterface::getConfig will be removed in guzzlehttp/guzzle:8.0.
|
||||
*/
|
||||
public function getConfig(?string $option = null);
|
||||
public function getConfig(string $option = null);
|
||||
}
|
||||
|
||||
@@ -80,19 +80,13 @@ class CookieJar implements \WPMailSMTP\Vendor\GuzzleHttp\Cookie\CookieJarInterfa
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function toArray() : array
|
||||
{
|
||||
return \array_map(static function (\WPMailSMTP\Vendor\GuzzleHttp\Cookie\SetCookie $cookie) : array {
|
||||
return $cookie->toArray();
|
||||
}, $this->getIterator()->getArrayCopy());
|
||||
}
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function clear(?string $domain = null, ?string $path = null, ?string $name = null) : void
|
||||
public function clear(string $domain = null, string $path = null, string $name = null) : void
|
||||
{
|
||||
if (!$domain) {
|
||||
$this->cookies = [];
|
||||
@@ -111,18 +105,12 @@ class CookieJar implements \WPMailSMTP\Vendor\GuzzleHttp\Cookie\CookieJarInterfa
|
||||
});
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function clearSessionCookies() : void
|
||||
{
|
||||
$this->cookies = \array_filter($this->cookies, static function (\WPMailSMTP\Vendor\GuzzleHttp\Cookie\SetCookie $cookie) : bool {
|
||||
return !$cookie->getDiscard() && $cookie->getExpires();
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setCookie(\WPMailSMTP\Vendor\GuzzleHttp\Cookie\SetCookie $cookie) : bool
|
||||
{
|
||||
// If the name string is empty (but not 0), ignore the set-cookie
|
||||
@@ -204,7 +192,7 @@ class CookieJar implements \WPMailSMTP\Vendor\GuzzleHttp\Cookie\CookieJarInterfa
|
||||
/**
|
||||
* Computes cookie path following RFC 6265 section 5.1.4
|
||||
*
|
||||
* @link https://tools.ietf.org/html/rfc6265#section-5.1.4
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc6265#section-5.1.4
|
||||
*/
|
||||
private function getCookiePathFromRequest(\WPMailSMTP\Vendor\Psr\Http\Message\RequestInterface $request) : string
|
||||
{
|
||||
|
||||
@@ -12,7 +12,8 @@ use WPMailSMTP\Vendor\Psr\Http\Message\ResponseInterface;
|
||||
* necessary. Subclasses are also responsible for storing and retrieving
|
||||
* cookies from a file, database, etc.
|
||||
*
|
||||
* @link https://docs.python.org/2/library/cookielib.html Inspiration
|
||||
* @see https://docs.python.org/2/library/cookielib.html Inspiration
|
||||
*
|
||||
* @extends \IteratorAggregate<SetCookie>
|
||||
*/
|
||||
interface CookieJarInterface extends \Countable, \IteratorAggregate
|
||||
@@ -57,7 +58,7 @@ interface CookieJarInterface extends \Countable, \IteratorAggregate
|
||||
* @param string|null $path Clears cookies matching a domain and path
|
||||
* @param string|null $name Clears cookies matching a domain, path, and name
|
||||
*/
|
||||
public function clear(?string $domain = null, ?string $path = null, ?string $name = null) : void;
|
||||
public function clear(string $domain = null, string $path = null, string $name = null) : void;
|
||||
/**
|
||||
* Discard all sessions cookies.
|
||||
*
|
||||
|
||||
@@ -65,7 +65,7 @@ class SessionCookieJar extends \WPMailSMTP\Vendor\GuzzleHttp\Cookie\CookieJar
|
||||
$this->setCookie(new \WPMailSMTP\Vendor\GuzzleHttp\Cookie\SetCookie($cookie));
|
||||
}
|
||||
} elseif (\strlen($data)) {
|
||||
throw new \RuntimeException("Invalid cookie data");
|
||||
throw new \RuntimeException('Invalid cookie data');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,13 @@ class SetCookie
|
||||
} else {
|
||||
foreach (\array_keys(self::$defaults) as $search) {
|
||||
if (!\strcasecmp($search, $key)) {
|
||||
$data[$search] = $value;
|
||||
if ($search === 'Max-Age') {
|
||||
if (\is_numeric($value)) {
|
||||
$data[$search] = (int) $value;
|
||||
}
|
||||
} else {
|
||||
$data[$search] = $value;
|
||||
}
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
@@ -56,12 +62,38 @@ class SetCookie
|
||||
*/
|
||||
public function __construct(array $data = [])
|
||||
{
|
||||
/** @var array|null $replaced will be null in case of replace error */
|
||||
$replaced = \array_replace(self::$defaults, $data);
|
||||
if ($replaced === null) {
|
||||
throw new \InvalidArgumentException('Unable to replace the default values for the Cookie.');
|
||||
$this->data = self::$defaults;
|
||||
if (isset($data['Name'])) {
|
||||
$this->setName($data['Name']);
|
||||
}
|
||||
if (isset($data['Value'])) {
|
||||
$this->setValue($data['Value']);
|
||||
}
|
||||
if (isset($data['Domain'])) {
|
||||
$this->setDomain($data['Domain']);
|
||||
}
|
||||
if (isset($data['Path'])) {
|
||||
$this->setPath($data['Path']);
|
||||
}
|
||||
if (isset($data['Max-Age'])) {
|
||||
$this->setMaxAge($data['Max-Age']);
|
||||
}
|
||||
if (isset($data['Expires'])) {
|
||||
$this->setExpires($data['Expires']);
|
||||
}
|
||||
if (isset($data['Secure'])) {
|
||||
$this->setSecure($data['Secure']);
|
||||
}
|
||||
if (isset($data['Discard'])) {
|
||||
$this->setDiscard($data['Discard']);
|
||||
}
|
||||
if (isset($data['HttpOnly'])) {
|
||||
$this->setHttpOnly($data['HttpOnly']);
|
||||
}
|
||||
// Set the remaining values that don't have extra validation logic
|
||||
foreach (\array_diff(\array_keys($data), \array_keys(self::$defaults)) as $key) {
|
||||
$this->data[$key] = $data[$key];
|
||||
}
|
||||
$this->data = $replaced;
|
||||
// Extract the Expires value and turn it into a UNIX timestamp if needed
|
||||
if (!$this->getExpires() && $this->getMaxAge()) {
|
||||
// Calculate the Expires date
|
||||
@@ -322,7 +354,7 @@ class SetCookie
|
||||
return \true;
|
||||
}
|
||||
// Remove the leading '.' as per spec in RFC 6265.
|
||||
// https://tools.ietf.org/html/rfc6265#section-5.2.3
|
||||
// https://datatracker.ietf.org/doc/html/rfc6265#section-5.2.3
|
||||
$cookieDomain = \ltrim(\strtolower($cookieDomain), '.');
|
||||
$domain = \strtolower($domain);
|
||||
// Domain not set or exact match.
|
||||
@@ -330,7 +362,7 @@ class SetCookie
|
||||
return \true;
|
||||
}
|
||||
// Matching the subdomain according to RFC 6265.
|
||||
// https://tools.ietf.org/html/rfc6265#section-5.1.3
|
||||
// https://datatracker.ietf.org/doc/html/rfc6265#section-5.1.3
|
||||
if (\filter_var($domain, \FILTER_VALIDATE_IP)) {
|
||||
return \false;
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ class CurlFactory implements \WPMailSMTP\Vendor\GuzzleHttp\Handler\CurlFactoryIn
|
||||
*/
|
||||
private function getDefaultConf(\WPMailSMTP\Vendor\GuzzleHttp\Handler\EasyHandle $easy) : array
|
||||
{
|
||||
$conf = ['_headers' => $easy->request->getHeaders(), \CURLOPT_CUSTOMREQUEST => $easy->request->getMethod(), \CURLOPT_URL => (string) $easy->request->getUri()->withFragment(''), \CURLOPT_RETURNTRANSFER => \false, \CURLOPT_HEADER => \false, \CURLOPT_CONNECTTIMEOUT => 150];
|
||||
$conf = ['_headers' => $easy->request->getHeaders(), \CURLOPT_CUSTOMREQUEST => $easy->request->getMethod(), \CURLOPT_URL => (string) $easy->request->getUri()->withFragment(''), \CURLOPT_RETURNTRANSFER => \false, \CURLOPT_HEADER => \false, \CURLOPT_CONNECTTIMEOUT => 300];
|
||||
if (\defined('CURLOPT_PROTOCOLS')) {
|
||||
$conf[\CURLOPT_PROTOCOLS] = \CURLPROTO_HTTP | \CURLPROTO_HTTPS;
|
||||
}
|
||||
@@ -175,7 +175,7 @@ class CurlFactory implements \WPMailSMTP\Vendor\GuzzleHttp\Handler\CurlFactoryIn
|
||||
}
|
||||
$method = $easy->request->getMethod();
|
||||
if ($method === 'PUT' || $method === 'POST') {
|
||||
// See https://tools.ietf.org/html/rfc7230#section-3.3.2
|
||||
// See https://datatracker.ietf.org/doc/html/rfc7230#section-3.3.2
|
||||
if (!$easy->request->hasHeader('Content-Length')) {
|
||||
$conf[\CURLOPT_HTTPHEADER][] = 'Content-Length: 0';
|
||||
}
|
||||
@@ -334,12 +334,39 @@ class CurlFactory implements \WPMailSMTP\Vendor\GuzzleHttp\Handler\CurlFactoryIn
|
||||
$scheme = $easy->request->getUri()->getScheme();
|
||||
if (isset($options['proxy'][$scheme])) {
|
||||
$host = $easy->request->getUri()->getHost();
|
||||
if (!isset($options['proxy']['no']) || !\WPMailSMTP\Vendor\GuzzleHttp\Utils::isHostInNoProxy($host, $options['proxy']['no'])) {
|
||||
if (isset($options['proxy']['no']) && \WPMailSMTP\Vendor\GuzzleHttp\Utils::isHostInNoProxy($host, $options['proxy']['no'])) {
|
||||
unset($conf[\CURLOPT_PROXY]);
|
||||
} else {
|
||||
$conf[\CURLOPT_PROXY] = $options['proxy'][$scheme];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($options['crypto_method'])) {
|
||||
if (\STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT === $options['crypto_method']) {
|
||||
if (!\defined('CURL_SSLVERSION_TLSv1_0')) {
|
||||
throw new \InvalidArgumentException('Invalid crypto_method request option: TLS 1.0 not supported by your version of cURL');
|
||||
}
|
||||
$conf[\CURLOPT_SSLVERSION] = \CURL_SSLVERSION_TLSv1_0;
|
||||
} elseif (\STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT === $options['crypto_method']) {
|
||||
if (!\defined('CURL_SSLVERSION_TLSv1_1')) {
|
||||
throw new \InvalidArgumentException('Invalid crypto_method request option: TLS 1.1 not supported by your version of cURL');
|
||||
}
|
||||
$conf[\CURLOPT_SSLVERSION] = \CURL_SSLVERSION_TLSv1_1;
|
||||
} elseif (\STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT === $options['crypto_method']) {
|
||||
if (!\defined('CURL_SSLVERSION_TLSv1_2')) {
|
||||
throw new \InvalidArgumentException('Invalid crypto_method request option: TLS 1.2 not supported by your version of cURL');
|
||||
}
|
||||
$conf[\CURLOPT_SSLVERSION] = \CURL_SSLVERSION_TLSv1_2;
|
||||
} elseif (\defined('STREAM_CRYPTO_METHOD_TLSv1_3_CLIENT') && \STREAM_CRYPTO_METHOD_TLSv1_3_CLIENT === $options['crypto_method']) {
|
||||
if (!\defined('CURL_SSLVERSION_TLSv1_3')) {
|
||||
throw new \InvalidArgumentException('Invalid crypto_method request option: TLS 1.3 not supported by your version of cURL');
|
||||
}
|
||||
$conf[\CURLOPT_SSLVERSION] = \CURL_SSLVERSION_TLSv1_3;
|
||||
} else {
|
||||
throw new \InvalidArgumentException('Invalid crypto_method request option: unknown version provided');
|
||||
}
|
||||
}
|
||||
if (isset($options['cert'])) {
|
||||
$cert = $options['cert'];
|
||||
if (\is_array($cert)) {
|
||||
@@ -349,8 +376,8 @@ class CurlFactory implements \WPMailSMTP\Vendor\GuzzleHttp\Handler\CurlFactoryIn
|
||||
if (!\file_exists($cert)) {
|
||||
throw new \InvalidArgumentException("SSL certificate not found: {$cert}");
|
||||
}
|
||||
# OpenSSL (versions 0.9.3 and later) also support "P12" for PKCS#12-encoded files.
|
||||
# see https://curl.se/libcurl/c/CURLOPT_SSLCERTTYPE.html
|
||||
// OpenSSL (versions 0.9.3 and later) also support "P12" for PKCS#12-encoded files.
|
||||
// see https://curl.se/libcurl/c/CURLOPT_SSLCERTTYPE.html
|
||||
$ext = \pathinfo($cert, \PATHINFO_EXTENSION);
|
||||
if (\preg_match('#^(der|p12)$#i', $ext)) {
|
||||
$conf[\CURLOPT_SSLCERTTYPE] = \strtoupper($ext);
|
||||
@@ -416,7 +443,7 @@ class CurlFactory implements \WPMailSMTP\Vendor\GuzzleHttp\Handler\CurlFactoryIn
|
||||
$ctx['error'] = 'The cURL request was retried 3 times ' . 'and did not succeed. The most likely reason for the failure ' . 'is that cURL was unable to rewind the body of the request ' . 'and subsequent retries resulted in the same error. Turn on ' . 'the debug option to see what went wrong. See ' . 'https://bugs.php.net/bug.php?id=47204 for more information.';
|
||||
return self::createRejection($easy, $ctx);
|
||||
} else {
|
||||
$easy->options['_curl_retries']++;
|
||||
++$easy->options['_curl_retries'];
|
||||
}
|
||||
return $handler($easy->request, $easy->options);
|
||||
}
|
||||
@@ -459,4 +486,11 @@ class CurlFactory implements \WPMailSMTP\Vendor\GuzzleHttp\Handler\CurlFactoryIn
|
||||
return \strlen($h);
|
||||
};
|
||||
}
|
||||
public function __destruct()
|
||||
{
|
||||
foreach ($this->handles as $id => $handle) {
|
||||
\curl_close($handle);
|
||||
unset($this->handles[$id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,8 +14,6 @@ use WPMailSMTP\Vendor\Psr\Http\Message\RequestInterface;
|
||||
* associative array of curl option constants mapping to values in the
|
||||
* **curl** key of the provided request options.
|
||||
*
|
||||
* @property resource|\CurlMultiHandle $_mh Internal use only. Lazy loaded multi-handle.
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class CurlMultiHandler
|
||||
@@ -48,6 +46,8 @@ class CurlMultiHandler
|
||||
* @var array<mixed> An associative array of CURLMOPT_* options and corresponding values for curl_multi_setopt()
|
||||
*/
|
||||
private $options = [];
|
||||
/** @var resource|\CurlMultiHandle */
|
||||
private $_mh;
|
||||
/**
|
||||
* This handler accepts the following options:
|
||||
*
|
||||
@@ -69,6 +69,9 @@ class CurlMultiHandler
|
||||
$this->selectTimeout = 1;
|
||||
}
|
||||
$this->options = $options['options'] ?? [];
|
||||
// unsetting the property forces the first access to go through
|
||||
// __get().
|
||||
unset($this->_mh);
|
||||
}
|
||||
/**
|
||||
* @param string $name
|
||||
|
||||
@@ -13,9 +13,9 @@ final class HeaderProcessor
|
||||
*
|
||||
* @param string[] $headers
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*
|
||||
* @return array{0:string, 1:int, 2:?string, 3:array}
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public static function parseHeaders(array $headers) : array
|
||||
{
|
||||
|
||||
@@ -53,7 +53,7 @@ class StreamHandler
|
||||
// Determine if the error was a networking error.
|
||||
$message = $e->getMessage();
|
||||
// This list can probably get more comprehensive.
|
||||
if (\false !== \strpos($message, 'getaddrinfo') || \false !== \strpos($message, 'Connection refused') || \false !== \strpos($message, "couldn't connect to host") || \false !== \strpos($message, "connection attempt failed")) {
|
||||
if (\false !== \strpos($message, 'getaddrinfo') || \false !== \strpos($message, 'Connection refused') || \false !== \strpos($message, "couldn't connect to host") || \false !== \strpos($message, 'connection attempt failed')) {
|
||||
$e = new \WPMailSMTP\Vendor\GuzzleHttp\Exception\ConnectException($e->getMessage(), $request, $e);
|
||||
} else {
|
||||
$e = \WPMailSMTP\Vendor\GuzzleHttp\Exception\RequestException::wrapException($request, $e);
|
||||
@@ -290,7 +290,7 @@ class StreamHandler
|
||||
}
|
||||
$context = ['http' => ['method' => $request->getMethod(), 'header' => $headers, 'protocol_version' => $request->getProtocolVersion(), 'ignore_errors' => \true, 'follow_location' => 0], 'ssl' => ['peer_name' => $request->getUri()->getHost()]];
|
||||
$body = (string) $request->getBody();
|
||||
if (!empty($body)) {
|
||||
if ('' !== $body) {
|
||||
$context['http']['content'] = $body;
|
||||
// Prevent the HTTP handler from adding a Content-Type header.
|
||||
if (!$request->hasHeader('Content-Type')) {
|
||||
@@ -355,6 +355,17 @@ class StreamHandler
|
||||
$options['http']['timeout'] = $value;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param mixed $value as passed via Request transfer options.
|
||||
*/
|
||||
private function add_crypto_method(\WPMailSMTP\Vendor\Psr\Http\Message\RequestInterface $request, array &$options, $value, array &$params) : void
|
||||
{
|
||||
if ($value === \STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT || $value === \STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT || $value === \STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT || \defined('STREAM_CRYPTO_METHOD_TLSv1_3_CLIENT') && $value === \STREAM_CRYPTO_METHOD_TLSv1_3_CLIENT) {
|
||||
$options['http']['crypto_method'] = $value;
|
||||
return;
|
||||
}
|
||||
throw new \InvalidArgumentException('Invalid crypto_method request option: unknown version provided');
|
||||
}
|
||||
/**
|
||||
* @param mixed $value as passed via Request transfer options.
|
||||
*/
|
||||
|
||||
@@ -40,7 +40,7 @@ class HandlerStack
|
||||
* handler is provided, the best handler for your
|
||||
* system will be utilized.
|
||||
*/
|
||||
public static function create(?callable $handler = null) : self
|
||||
public static function create(callable $handler = null) : self
|
||||
{
|
||||
$stack = new self($handler ?: \WPMailSMTP\Vendor\GuzzleHttp\Utils::chooseHandler());
|
||||
$stack->push(\WPMailSMTP\Vendor\GuzzleHttp\Middleware::httpErrors(), 'http_errors');
|
||||
@@ -76,13 +76,13 @@ class HandlerStack
|
||||
$depth = 0;
|
||||
$stack = [];
|
||||
if ($this->handler !== null) {
|
||||
$stack[] = "0) Handler: " . $this->debugCallable($this->handler);
|
||||
$stack[] = '0) Handler: ' . $this->debugCallable($this->handler);
|
||||
}
|
||||
$result = '';
|
||||
foreach (\array_reverse($this->stack) as $tuple) {
|
||||
$depth++;
|
||||
++$depth;
|
||||
$str = "{$depth}) Name: '{$tuple[1]}', ";
|
||||
$str .= "Function: " . $this->debugCallable($tuple[0]);
|
||||
$str .= 'Function: ' . $this->debugCallable($tuple[0]);
|
||||
$result = "> {$str}\n{$result}";
|
||||
$stack[] = $str;
|
||||
}
|
||||
@@ -115,7 +115,7 @@ class HandlerStack
|
||||
* @param callable(callable): callable $middleware Middleware function
|
||||
* @param string $name Name to register for this middleware.
|
||||
*/
|
||||
public function unshift(callable $middleware, ?string $name = null) : void
|
||||
public function unshift(callable $middleware, string $name = null) : void
|
||||
{
|
||||
\array_unshift($this->stack, [$middleware, $name]);
|
||||
$this->cached = null;
|
||||
|
||||
@@ -39,11 +39,11 @@ class MessageFormatter implements \WPMailSMTP\Vendor\GuzzleHttp\MessageFormatter
|
||||
/**
|
||||
* Apache Common Log Format.
|
||||
*
|
||||
* @link https://httpd.apache.org/docs/2.4/logs.html#common
|
||||
* @see https://httpd.apache.org/docs/2.4/logs.html#common
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public const CLF = "{hostname} {req_header_User-Agent} - [{date_common_log}] \"{method} {target} HTTP/{version}\" {code} {res_header_Content-Length}";
|
||||
public const CLF = '{hostname} {req_header_User-Agent} - [{date_common_log}] "{method} {target} HTTP/{version}" {code} {res_header_Content-Length}';
|
||||
public const DEBUG = ">>>>>>>>\n{request}\n<<<<<<<<\n{response}\n--------\n{error}";
|
||||
public const SHORT = '[{ts}] "{method} {target} HTTP/{version}" {code}';
|
||||
/**
|
||||
@@ -64,7 +64,7 @@ class MessageFormatter implements \WPMailSMTP\Vendor\GuzzleHttp\MessageFormatter
|
||||
* @param ResponseInterface|null $response Response that was received
|
||||
* @param \Throwable|null $error Exception that was received
|
||||
*/
|
||||
public function format(\WPMailSMTP\Vendor\Psr\Http\Message\RequestInterface $request, ?\WPMailSMTP\Vendor\Psr\Http\Message\ResponseInterface $response = null, ?\Throwable $error = null) : string
|
||||
public function format(\WPMailSMTP\Vendor\Psr\Http\Message\RequestInterface $request, \WPMailSMTP\Vendor\Psr\Http\Message\ResponseInterface $response = null, \Throwable $error = null) : string
|
||||
{
|
||||
$cache = [];
|
||||
/** @var string */
|
||||
|
||||
@@ -13,5 +13,5 @@ interface MessageFormatterInterface
|
||||
* @param ResponseInterface|null $response Response that was received
|
||||
* @param \Throwable|null $error Exception that was received
|
||||
*/
|
||||
public function format(\WPMailSMTP\Vendor\Psr\Http\Message\RequestInterface $request, ?\WPMailSMTP\Vendor\Psr\Http\Message\ResponseInterface $response = null, ?\Throwable $error = null) : string;
|
||||
public function format(\WPMailSMTP\Vendor\Psr\Http\Message\RequestInterface $request, \WPMailSMTP\Vendor\Psr\Http\Message\ResponseInterface $response = null, \Throwable $error = null) : string;
|
||||
}
|
||||
|
||||
@@ -5,9 +5,7 @@ namespace WPMailSMTP\Vendor\GuzzleHttp;
|
||||
/**
|
||||
* This class contains a list of built-in Guzzle request options.
|
||||
*
|
||||
* More documentation for each option can be found at http://guzzlephp.org/.
|
||||
*
|
||||
* @link http://docs.guzzlephp.org/en/v6/request-options.html
|
||||
* @see https://docs.guzzlephp.org/en/latest/request-options.html
|
||||
*/
|
||||
final class RequestOptions
|
||||
{
|
||||
@@ -65,9 +63,20 @@ final class RequestOptions
|
||||
/**
|
||||
* connect_timeout: (float, default=0) Float describing the number of
|
||||
* seconds to wait while trying to connect to a server. Use 0 to wait
|
||||
* indefinitely (the default behavior).
|
||||
* 300 seconds (the default behavior).
|
||||
*/
|
||||
public const CONNECT_TIMEOUT = 'connect_timeout';
|
||||
/**
|
||||
* crypto_method: (int) A value describing the minimum TLS protocol
|
||||
* version to use.
|
||||
*
|
||||
* This setting must be set to one of the
|
||||
* ``STREAM_CRYPTO_METHOD_TLS*_CLIENT`` constants. PHP 7.4 or higher is
|
||||
* required in order to use TLS 1.3, and cURL 7.34.0 or higher is required
|
||||
* in order to specify a crypto method, with cURL 7.52.0 or higher being
|
||||
* required to use TLS 1.3.
|
||||
*/
|
||||
public const CRYPTO_METHOD = 'crypto_method';
|
||||
/**
|
||||
* debug: (bool|resource) Set to true or set to a PHP stream returned by
|
||||
* fopen() enable debug output with the HTTP handler used to send a
|
||||
|
||||
@@ -49,7 +49,7 @@ class RetryMiddleware
|
||||
*/
|
||||
public static function exponentialDelay(int $retries) : int
|
||||
{
|
||||
return (int) \pow(2, $retries - 1) * 1000;
|
||||
return (int) 2 ** ($retries - 1) * 1000;
|
||||
}
|
||||
public function __invoke(\WPMailSMTP\Vendor\Psr\Http\Message\RequestInterface $request, array $options) : \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
{
|
||||
@@ -85,7 +85,7 @@ class RetryMiddleware
|
||||
}
|
||||
private function doRetry(\WPMailSMTP\Vendor\Psr\Http\Message\RequestInterface $request, array $options, \WPMailSMTP\Vendor\Psr\Http\Message\ResponseInterface $response = null) : \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
{
|
||||
$options['delay'] = ($this->delay)(++$options['retries'], $response);
|
||||
$options['delay'] = ($this->delay)(++$options['retries'], $response, $request);
|
||||
return $this($request, $options);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ final class TransferStats
|
||||
* @param mixed $handlerErrorData Handler error data.
|
||||
* @param array $handlerStats Handler specific stats.
|
||||
*/
|
||||
public function __construct(\WPMailSMTP\Vendor\Psr\Http\Message\RequestInterface $request, ?\WPMailSMTP\Vendor\Psr\Http\Message\ResponseInterface $response = null, ?float $transferTime = null, $handlerErrorData = null, array $handlerStats = [])
|
||||
public function __construct(\WPMailSMTP\Vendor\Psr\Http\Message\RequestInterface $request, \WPMailSMTP\Vendor\Psr\Http\Message\ResponseInterface $response = null, float $transferTime = null, $handlerErrorData = null, array $handlerStats = [])
|
||||
{
|
||||
$this->request = $request;
|
||||
$this->response = $response;
|
||||
|
||||
@@ -71,19 +71,21 @@ final class Utils
|
||||
*
|
||||
* The returned handler is not wrapped by any default middlewares.
|
||||
*
|
||||
* @throws \RuntimeException if no viable Handler is available.
|
||||
*
|
||||
* @return callable(\Psr\Http\Message\RequestInterface, array): \GuzzleHttp\Promise\PromiseInterface Returns the best handler for the given system.
|
||||
*
|
||||
* @throws \RuntimeException if no viable Handler is available.
|
||||
*/
|
||||
public static function chooseHandler() : callable
|
||||
{
|
||||
$handler = null;
|
||||
if (\function_exists('curl_multi_exec') && \function_exists('curl_exec')) {
|
||||
$handler = \WPMailSMTP\Vendor\GuzzleHttp\Handler\Proxy::wrapSync(new \WPMailSMTP\Vendor\GuzzleHttp\Handler\CurlMultiHandler(), new \WPMailSMTP\Vendor\GuzzleHttp\Handler\CurlHandler());
|
||||
} elseif (\function_exists('curl_exec')) {
|
||||
$handler = new \WPMailSMTP\Vendor\GuzzleHttp\Handler\CurlHandler();
|
||||
} elseif (\function_exists('curl_multi_exec')) {
|
||||
$handler = new \WPMailSMTP\Vendor\GuzzleHttp\Handler\CurlMultiHandler();
|
||||
if (\defined('CURLOPT_CUSTOMREQUEST')) {
|
||||
if (\function_exists('curl_multi_exec') && \function_exists('curl_exec')) {
|
||||
$handler = \WPMailSMTP\Vendor\GuzzleHttp\Handler\Proxy::wrapSync(new \WPMailSMTP\Vendor\GuzzleHttp\Handler\CurlMultiHandler(), new \WPMailSMTP\Vendor\GuzzleHttp\Handler\CurlHandler());
|
||||
} elseif (\function_exists('curl_exec')) {
|
||||
$handler = new \WPMailSMTP\Vendor\GuzzleHttp\Handler\CurlHandler();
|
||||
} elseif (\function_exists('curl_multi_exec')) {
|
||||
$handler = new \WPMailSMTP\Vendor\GuzzleHttp\Handler\CurlMultiHandler();
|
||||
}
|
||||
}
|
||||
if (\ini_get('allow_url_fopen')) {
|
||||
$handler = $handler ? \WPMailSMTP\Vendor\GuzzleHttp\Handler\Proxy::wrapStreaming($handler, new \WPMailSMTP\Vendor\GuzzleHttp\Handler\StreamHandler()) : new \WPMailSMTP\Vendor\GuzzleHttp\Handler\StreamHandler();
|
||||
@@ -153,14 +155,13 @@ No system CA bundle could be found in any of the the common system locations.
|
||||
PHP versions earlier than 5.6 are not properly configured to use the system's
|
||||
CA bundle by default. In order to verify peer certificates, you will need to
|
||||
supply the path on disk to a certificate bundle to the 'verify' request
|
||||
option: http://docs.guzzlephp.org/en/latest/clients.html#verify. If you do not
|
||||
need a specific certificate bundle, then Mozilla provides a commonly used CA
|
||||
bundle which can be downloaded here (provided by the maintainer of cURL):
|
||||
https://curl.haxx.se/ca/cacert.pem. Once
|
||||
you have a CA bundle available on disk, you can set the 'openssl.cafile' PHP
|
||||
ini setting to point to the path to the file, allowing you to omit the 'verify'
|
||||
request option. See https://curl.haxx.se/docs/sslcerts.html for more
|
||||
information.
|
||||
option: https://docs.guzzlephp.org/en/latest/request-options.html#verify. If
|
||||
you do not need a specific certificate bundle, then Mozilla provides a commonly
|
||||
used CA bundle which can be downloaded here (provided by the maintainer of
|
||||
cURL): https://curl.haxx.se/ca/cacert.pem. Once you have a CA bundle available
|
||||
on disk, you can set the 'openssl.cafile' PHP ini setting to point to the path
|
||||
to the file, allowing you to omit the 'verify' request option. See
|
||||
https://curl.haxx.se/docs/sslcerts.html for more information.
|
||||
EOT
|
||||
);
|
||||
}
|
||||
@@ -237,7 +238,7 @@ EOT
|
||||
*
|
||||
* @throws InvalidArgumentException if the JSON cannot be decoded.
|
||||
*
|
||||
* @link https://www.php.net/manual/en/function.json-decode.php
|
||||
* @see https://www.php.net/manual/en/function.json-decode.php
|
||||
*/
|
||||
public static function jsonDecode(string $json, bool $assoc = \false, int $depth = 512, int $options = 0)
|
||||
{
|
||||
@@ -256,7 +257,7 @@ EOT
|
||||
*
|
||||
* @throws InvalidArgumentException if the JSON cannot be encoded.
|
||||
*
|
||||
* @link https://www.php.net/manual/en/function.json-encode.php
|
||||
* @see https://www.php.net/manual/en/function.json-encode.php
|
||||
*/
|
||||
public static function jsonEncode($value, int $options = 0, int $depth = 512) : string
|
||||
{
|
||||
|
||||
@@ -47,10 +47,10 @@ function debug_resource($value = null)
|
||||
*
|
||||
* The returned handler is not wrapped by any default middlewares.
|
||||
*
|
||||
* @throws \RuntimeException if no viable Handler is available.
|
||||
*
|
||||
* @return callable(\Psr\Http\Message\RequestInterface, array): \GuzzleHttp\Promise\PromiseInterface Returns the best handler for the given system.
|
||||
*
|
||||
* @throws \RuntimeException if no viable Handler is available.
|
||||
*
|
||||
* @deprecated choose_handler will be removed in guzzlehttp/guzzle:8.0. Use Utils::chooseHandler instead.
|
||||
*/
|
||||
function choose_handler() : callable
|
||||
@@ -133,7 +133,7 @@ function is_host_in_noproxy(string $host, array $noProxyArray) : bool
|
||||
*
|
||||
* @throws Exception\InvalidArgumentException if the JSON cannot be decoded.
|
||||
*
|
||||
* @link https://www.php.net/manual/en/function.json-decode.php
|
||||
* @see https://www.php.net/manual/en/function.json-decode.php
|
||||
* @deprecated json_decode will be removed in guzzlehttp/guzzle:8.0. Use Utils::jsonDecode instead.
|
||||
*/
|
||||
function json_decode(string $json, bool $assoc = \false, int $depth = 512, int $options = 0)
|
||||
@@ -149,7 +149,7 @@ function json_decode(string $json, bool $assoc = \false, int $depth = 512, int $
|
||||
*
|
||||
* @throws Exception\InvalidArgumentException if the JSON cannot be encoded.
|
||||
*
|
||||
* @link https://www.php.net/manual/en/function.json-encode.php
|
||||
* @see https://www.php.net/manual/en/function.json-encode.php
|
||||
* @deprecated json_encode will be removed in guzzlehttp/guzzle:8.0. Use Utils::jsonEncode instead.
|
||||
*/
|
||||
function json_encode($value, int $options = 0, int $depth = 512) : string
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace WPMailSMTP\Vendor\GuzzleHttp\Promise;
|
||||
|
||||
/**
|
||||
@@ -7,7 +8,7 @@ namespace WPMailSMTP\Vendor\GuzzleHttp\Promise;
|
||||
*/
|
||||
class AggregateException extends \WPMailSMTP\Vendor\GuzzleHttp\Promise\RejectionException
|
||||
{
|
||||
public function __construct($msg, array $reasons)
|
||||
public function __construct(string $msg, array $reasons)
|
||||
{
|
||||
parent::__construct($reasons, \sprintf('%s; %d rejected promises', $msg, \count($reasons)));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace WPMailSMTP\Vendor\GuzzleHttp\Promise;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace WPMailSMTP\Vendor\GuzzleHttp\Promise;
|
||||
|
||||
use Exception;
|
||||
use Generator;
|
||||
use Throwable;
|
||||
/**
|
||||
@@ -26,7 +26,7 @@ use Throwable;
|
||||
* $value = (yield createPromise('a'));
|
||||
* try {
|
||||
* $value = (yield createPromise($value . 'b'));
|
||||
* } catch (\Exception $e) {
|
||||
* } catch (\Throwable $e) {
|
||||
* // The promise was rejected.
|
||||
* }
|
||||
* yield $value . 'c';
|
||||
@@ -39,7 +39,7 @@ use Throwable;
|
||||
*
|
||||
* @return Promise
|
||||
*
|
||||
* @link https://github.com/petkaantonov/bluebird/blob/master/API.md#generators inspiration
|
||||
* @see https://github.com/petkaantonov/bluebird/blob/master/API.md#generators inspiration
|
||||
*/
|
||||
final class Coroutine implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
{
|
||||
@@ -58,65 +58,61 @@ final class Coroutine implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseIn
|
||||
public function __construct(callable $generatorFn)
|
||||
{
|
||||
$this->generator = $generatorFn();
|
||||
$this->result = new \WPMailSMTP\Vendor\GuzzleHttp\Promise\Promise(function () {
|
||||
$this->result = new \WPMailSMTP\Vendor\GuzzleHttp\Promise\Promise(function () : void {
|
||||
while (isset($this->currentPromise)) {
|
||||
$this->currentPromise->wait();
|
||||
}
|
||||
});
|
||||
try {
|
||||
$this->nextCoroutine($this->generator->current());
|
||||
} catch (\Exception $exception) {
|
||||
$this->result->reject($exception);
|
||||
} catch (\Throwable $throwable) {
|
||||
$this->result->reject($throwable);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Create a new coroutine.
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public static function of(callable $generatorFn)
|
||||
public static function of(callable $generatorFn) : self
|
||||
{
|
||||
return new self($generatorFn);
|
||||
}
|
||||
public function then(callable $onFulfilled = null, callable $onRejected = null)
|
||||
public function then(callable $onFulfilled = null, callable $onRejected = null) : \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
{
|
||||
return $this->result->then($onFulfilled, $onRejected);
|
||||
}
|
||||
public function otherwise(callable $onRejected)
|
||||
public function otherwise(callable $onRejected) : \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
{
|
||||
return $this->result->otherwise($onRejected);
|
||||
}
|
||||
public function wait($unwrap = \true)
|
||||
public function wait(bool $unwrap = \true)
|
||||
{
|
||||
return $this->result->wait($unwrap);
|
||||
}
|
||||
public function getState()
|
||||
public function getState() : string
|
||||
{
|
||||
return $this->result->getState();
|
||||
}
|
||||
public function resolve($value)
|
||||
public function resolve($value) : void
|
||||
{
|
||||
$this->result->resolve($value);
|
||||
}
|
||||
public function reject($reason)
|
||||
public function reject($reason) : void
|
||||
{
|
||||
$this->result->reject($reason);
|
||||
}
|
||||
public function cancel()
|
||||
public function cancel() : void
|
||||
{
|
||||
$this->currentPromise->cancel();
|
||||
$this->result->cancel();
|
||||
}
|
||||
private function nextCoroutine($yielded)
|
||||
private function nextCoroutine($yielded) : void
|
||||
{
|
||||
$this->currentPromise = \WPMailSMTP\Vendor\GuzzleHttp\Promise\Create::promiseFor($yielded)->then([$this, '_handleSuccess'], [$this, '_handleFailure']);
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function _handleSuccess($value)
|
||||
public function _handleSuccess($value) : void
|
||||
{
|
||||
unset($this->currentPromise);
|
||||
try {
|
||||
@@ -126,8 +122,6 @@ final class Coroutine implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseIn
|
||||
} else {
|
||||
$this->result->resolve($value);
|
||||
}
|
||||
} catch (\Exception $exception) {
|
||||
$this->result->reject($exception);
|
||||
} catch (\Throwable $throwable) {
|
||||
$this->result->reject($throwable);
|
||||
}
|
||||
@@ -135,15 +129,13 @@ final class Coroutine implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseIn
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function _handleFailure($reason)
|
||||
public function _handleFailure($reason) : void
|
||||
{
|
||||
unset($this->currentPromise);
|
||||
try {
|
||||
$nextYield = $this->generator->throw(\WPMailSMTP\Vendor\GuzzleHttp\Promise\Create::exceptionFor($reason));
|
||||
// The throw was caught, so keep iterating on the coroutine
|
||||
$this->nextCoroutine($nextYield);
|
||||
} catch (\Exception $exception) {
|
||||
$this->result->reject($exception);
|
||||
} catch (\Throwable $throwable) {
|
||||
$this->result->reject($throwable);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace WPMailSMTP\Vendor\GuzzleHttp\Promise;
|
||||
|
||||
final class Create
|
||||
@@ -8,10 +9,8 @@ final class Create
|
||||
* Creates a promise for a value if the value is not a promise.
|
||||
*
|
||||
* @param mixed $value Promise or value.
|
||||
*
|
||||
* @return PromiseInterface
|
||||
*/
|
||||
public static function promiseFor($value)
|
||||
public static function promiseFor($value) : \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
{
|
||||
if ($value instanceof \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface) {
|
||||
return $value;
|
||||
@@ -31,10 +30,8 @@ final class Create
|
||||
* If the provided reason is a promise, then it is returned as-is.
|
||||
*
|
||||
* @param mixed $reason Promise or reason.
|
||||
*
|
||||
* @return PromiseInterface
|
||||
*/
|
||||
public static function rejectionFor($reason)
|
||||
public static function rejectionFor($reason) : \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
{
|
||||
if ($reason instanceof \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface) {
|
||||
return $reason;
|
||||
@@ -45,12 +42,10 @@ final class Create
|
||||
* Create an exception for a rejected promise value.
|
||||
*
|
||||
* @param mixed $reason
|
||||
*
|
||||
* @return \Exception|\Throwable
|
||||
*/
|
||||
public static function exceptionFor($reason)
|
||||
public static function exceptionFor($reason) : \Throwable
|
||||
{
|
||||
if ($reason instanceof \Exception || $reason instanceof \Throwable) {
|
||||
if ($reason instanceof \Throwable) {
|
||||
return $reason;
|
||||
}
|
||||
return new \WPMailSMTP\Vendor\GuzzleHttp\Promise\RejectionException($reason);
|
||||
@@ -59,10 +54,8 @@ final class Create
|
||||
* Returns an iterator for the given value.
|
||||
*
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return \Iterator
|
||||
*/
|
||||
public static function iterFor($value)
|
||||
public static function iterFor($value) : \Iterator
|
||||
{
|
||||
if ($value instanceof \Iterator) {
|
||||
return $value;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace WPMailSMTP\Vendor\GuzzleHttp\Promise;
|
||||
|
||||
final class Each
|
||||
@@ -17,13 +18,9 @@ final class Each
|
||||
* index, and the aggregate promise. The callback can invoke any necessary
|
||||
* side effects and choose to resolve or reject the aggregate if needed.
|
||||
*
|
||||
* @param mixed $iterable Iterator or array to iterate over.
|
||||
* @param callable $onFulfilled
|
||||
* @param callable $onRejected
|
||||
*
|
||||
* @return PromiseInterface
|
||||
* @param mixed $iterable Iterator or array to iterate over.
|
||||
*/
|
||||
public static function of($iterable, callable $onFulfilled = null, callable $onRejected = null)
|
||||
public static function of($iterable, callable $onFulfilled = null, callable $onRejected = null) : \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
{
|
||||
return (new \WPMailSMTP\Vendor\GuzzleHttp\Promise\EachPromise($iterable, ['fulfilled' => $onFulfilled, 'rejected' => $onRejected]))->promise();
|
||||
}
|
||||
@@ -37,12 +34,8 @@ final class Each
|
||||
*
|
||||
* @param mixed $iterable
|
||||
* @param int|callable $concurrency
|
||||
* @param callable $onFulfilled
|
||||
* @param callable $onRejected
|
||||
*
|
||||
* @return PromiseInterface
|
||||
*/
|
||||
public static function ofLimit($iterable, $concurrency, callable $onFulfilled = null, callable $onRejected = null)
|
||||
public static function ofLimit($iterable, $concurrency, callable $onFulfilled = null, callable $onRejected = null) : \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
{
|
||||
return (new \WPMailSMTP\Vendor\GuzzleHttp\Promise\EachPromise($iterable, ['fulfilled' => $onFulfilled, 'rejected' => $onRejected, 'concurrency' => $concurrency]))->promise();
|
||||
}
|
||||
@@ -53,13 +46,10 @@ final class Each
|
||||
*
|
||||
* @param mixed $iterable
|
||||
* @param int|callable $concurrency
|
||||
* @param callable $onFulfilled
|
||||
*
|
||||
* @return PromiseInterface
|
||||
*/
|
||||
public static function ofLimitAll($iterable, $concurrency, callable $onFulfilled = null)
|
||||
public static function ofLimitAll($iterable, $concurrency, callable $onFulfilled = null) : \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
{
|
||||
return self::ofLimit($iterable, $concurrency, $onFulfilled, function ($reason, $idx, \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface $aggregate) {
|
||||
return self::ofLimit($iterable, $concurrency, $onFulfilled, function ($reason, $idx, \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface $aggregate) : void {
|
||||
$aggregate->reject($reason);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace WPMailSMTP\Vendor\GuzzleHttp\Promise;
|
||||
|
||||
/**
|
||||
* Represents a promise that iterates over many promises and invokes
|
||||
* side-effect functions in the process.
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class EachPromise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromisorInterface
|
||||
{
|
||||
@@ -57,7 +60,7 @@ class EachPromise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromisorInter
|
||||
}
|
||||
}
|
||||
/** @psalm-suppress InvalidNullableReturnType */
|
||||
public function promise()
|
||||
public function promise() : \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
{
|
||||
if ($this->aggregate) {
|
||||
return $this->aggregate;
|
||||
@@ -69,19 +72,16 @@ class EachPromise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromisorInter
|
||||
$this->refillPending();
|
||||
} catch (\Throwable $e) {
|
||||
$this->aggregate->reject($e);
|
||||
} catch (\Exception $e) {
|
||||
$this->aggregate->reject($e);
|
||||
}
|
||||
/**
|
||||
* @psalm-suppress NullableReturnStatement
|
||||
* @phpstan-ignore-next-line
|
||||
*/
|
||||
return $this->aggregate;
|
||||
}
|
||||
private function createPromise()
|
||||
private function createPromise() : void
|
||||
{
|
||||
$this->mutex = \false;
|
||||
$this->aggregate = new \WPMailSMTP\Vendor\GuzzleHttp\Promise\Promise(function () {
|
||||
$this->aggregate = new \WPMailSMTP\Vendor\GuzzleHttp\Promise\Promise(function () : void {
|
||||
if ($this->checkIfFinished()) {
|
||||
return;
|
||||
}
|
||||
@@ -97,14 +97,14 @@ class EachPromise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromisorInter
|
||||
}
|
||||
});
|
||||
// Clear the references when the promise is resolved.
|
||||
$clearFn = function () {
|
||||
$clearFn = function () : void {
|
||||
$this->iterable = $this->concurrency = $this->pending = null;
|
||||
$this->onFulfilled = $this->onRejected = null;
|
||||
$this->nextPendingIndex = 0;
|
||||
};
|
||||
$this->aggregate->then($clearFn, $clearFn);
|
||||
}
|
||||
private function refillPending()
|
||||
private function refillPending() : void
|
||||
{
|
||||
if (!$this->concurrency) {
|
||||
// Add all pending promises.
|
||||
@@ -113,7 +113,7 @@ class EachPromise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromisorInter
|
||||
return;
|
||||
}
|
||||
// Add only up to N pending promises.
|
||||
$concurrency = \is_callable($this->concurrency) ? \call_user_func($this->concurrency, \count($this->pending)) : $this->concurrency;
|
||||
$concurrency = \is_callable($this->concurrency) ? ($this->concurrency)(\count($this->pending)) : $this->concurrency;
|
||||
$concurrency = \max($concurrency - \count($this->pending), 0);
|
||||
// Concurrency may be set to 0 to disallow new promises.
|
||||
if (!$concurrency) {
|
||||
@@ -128,7 +128,7 @@ class EachPromise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromisorInter
|
||||
while (--$concurrency && $this->advanceIterator() && $this->addPending()) {
|
||||
}
|
||||
}
|
||||
private function addPending()
|
||||
private function addPending() : bool
|
||||
{
|
||||
if (!$this->iterable || !$this->iterable->valid()) {
|
||||
return \false;
|
||||
@@ -138,20 +138,20 @@ class EachPromise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromisorInter
|
||||
// Iterable keys may not be unique, so we use a counter to
|
||||
// guarantee uniqueness
|
||||
$idx = $this->nextPendingIndex++;
|
||||
$this->pending[$idx] = $promise->then(function ($value) use($idx, $key) {
|
||||
$this->pending[$idx] = $promise->then(function ($value) use($idx, $key) : void {
|
||||
if ($this->onFulfilled) {
|
||||
\call_user_func($this->onFulfilled, $value, $key, $this->aggregate);
|
||||
($this->onFulfilled)($value, $key, $this->aggregate);
|
||||
}
|
||||
$this->step($idx);
|
||||
}, function ($reason) use($idx, $key) {
|
||||
}, function ($reason) use($idx, $key) : void {
|
||||
if ($this->onRejected) {
|
||||
\call_user_func($this->onRejected, $reason, $key, $this->aggregate);
|
||||
($this->onRejected)($reason, $key, $this->aggregate);
|
||||
}
|
||||
$this->step($idx);
|
||||
});
|
||||
return \true;
|
||||
}
|
||||
private function advanceIterator()
|
||||
private function advanceIterator() : bool
|
||||
{
|
||||
// Place a lock on the iterator so that we ensure to not recurse,
|
||||
// preventing fatal generator errors.
|
||||
@@ -167,13 +167,9 @@ class EachPromise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromisorInter
|
||||
$this->aggregate->reject($e);
|
||||
$this->mutex = \false;
|
||||
return \false;
|
||||
} catch (\Exception $e) {
|
||||
$this->aggregate->reject($e);
|
||||
$this->mutex = \false;
|
||||
return \false;
|
||||
}
|
||||
}
|
||||
private function step($idx)
|
||||
private function step(int $idx) : void
|
||||
{
|
||||
// If the promise was already resolved, then ignore this step.
|
||||
if (\WPMailSMTP\Vendor\GuzzleHttp\Promise\Is::settled($this->aggregate)) {
|
||||
@@ -188,7 +184,7 @@ class EachPromise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromisorInter
|
||||
$this->refillPending();
|
||||
}
|
||||
}
|
||||
private function checkIfFinished()
|
||||
private function checkIfFinished() : bool
|
||||
{
|
||||
if (!$this->pending && !$this->iterable->valid()) {
|
||||
// Resolve the promise if there's nothing left to do.
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace WPMailSMTP\Vendor\GuzzleHttp\Promise;
|
||||
|
||||
/**
|
||||
@@ -7,10 +8,15 @@ namespace WPMailSMTP\Vendor\GuzzleHttp\Promise;
|
||||
*
|
||||
* Thenning off of this promise will invoke the onFulfilled callback
|
||||
* immediately and ignore other callbacks.
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class FulfilledPromise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
{
|
||||
private $value;
|
||||
/**
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function __construct($value)
|
||||
{
|
||||
if (\is_object($value) && \method_exists($value, 'then')) {
|
||||
@@ -18,7 +24,7 @@ class FulfilledPromise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseI
|
||||
}
|
||||
$this->value = $value;
|
||||
}
|
||||
public function then(callable $onFulfilled = null, callable $onRejected = null)
|
||||
public function then(callable $onFulfilled = null, callable $onRejected = null) : \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
{
|
||||
// Return itself if there is no onFulfilled function.
|
||||
if (!$onFulfilled) {
|
||||
@@ -27,42 +33,40 @@ class FulfilledPromise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseI
|
||||
$queue = \WPMailSMTP\Vendor\GuzzleHttp\Promise\Utils::queue();
|
||||
$p = new \WPMailSMTP\Vendor\GuzzleHttp\Promise\Promise([$queue, 'run']);
|
||||
$value = $this->value;
|
||||
$queue->add(static function () use($p, $value, $onFulfilled) {
|
||||
$queue->add(static function () use($p, $value, $onFulfilled) : void {
|
||||
if (\WPMailSMTP\Vendor\GuzzleHttp\Promise\Is::pending($p)) {
|
||||
try {
|
||||
$p->resolve($onFulfilled($value));
|
||||
} catch (\Throwable $e) {
|
||||
$p->reject($e);
|
||||
} catch (\Exception $e) {
|
||||
$p->reject($e);
|
||||
}
|
||||
}
|
||||
});
|
||||
return $p;
|
||||
}
|
||||
public function otherwise(callable $onRejected)
|
||||
public function otherwise(callable $onRejected) : \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
{
|
||||
return $this->then(null, $onRejected);
|
||||
}
|
||||
public function wait($unwrap = \true, $defaultDelivery = null)
|
||||
public function wait(bool $unwrap = \true)
|
||||
{
|
||||
return $unwrap ? $this->value : null;
|
||||
}
|
||||
public function getState()
|
||||
public function getState() : string
|
||||
{
|
||||
return self::FULFILLED;
|
||||
}
|
||||
public function resolve($value)
|
||||
public function resolve($value) : void
|
||||
{
|
||||
if ($value !== $this->value) {
|
||||
throw new \LogicException("Cannot resolve a fulfilled promise");
|
||||
throw new \LogicException('Cannot resolve a fulfilled promise');
|
||||
}
|
||||
}
|
||||
public function reject($reason)
|
||||
public function reject($reason) : void
|
||||
{
|
||||
throw new \LogicException("Cannot reject a fulfilled promise");
|
||||
throw new \LogicException('Cannot reject a fulfilled promise');
|
||||
}
|
||||
public function cancel()
|
||||
public function cancel() : void
|
||||
{
|
||||
// pass
|
||||
}
|
||||
|
||||
@@ -1,42 +1,35 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace WPMailSMTP\Vendor\GuzzleHttp\Promise;
|
||||
|
||||
final class Is
|
||||
{
|
||||
/**
|
||||
* Returns true if a promise is pending.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function pending(\WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface $promise)
|
||||
public static function pending(\WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface $promise) : bool
|
||||
{
|
||||
return $promise->getState() === \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface::PENDING;
|
||||
}
|
||||
/**
|
||||
* Returns true if a promise is fulfilled or rejected.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function settled(\WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface $promise)
|
||||
public static function settled(\WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface $promise) : bool
|
||||
{
|
||||
return $promise->getState() !== \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface::PENDING;
|
||||
}
|
||||
/**
|
||||
* Returns true if a promise is fulfilled.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function fulfilled(\WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface $promise)
|
||||
public static function fulfilled(\WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface $promise) : bool
|
||||
{
|
||||
return $promise->getState() === \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface::FULFILLED;
|
||||
}
|
||||
/**
|
||||
* Returns true if a promise is rejected.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function rejected(\WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface $promise)
|
||||
public static function rejected(\WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface $promise) : bool
|
||||
{
|
||||
return $promise->getState() === \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface::REJECTED;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace WPMailSMTP\Vendor\GuzzleHttp\Promise;
|
||||
|
||||
/**
|
||||
* Promises/A+ implementation that avoids recursion when possible.
|
||||
*
|
||||
* @link https://promisesaplus.com/
|
||||
* @see https://promisesaplus.com/
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class Promise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
{
|
||||
@@ -24,7 +27,7 @@ class Promise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
$this->waitFn = $waitFn;
|
||||
$this->cancelFn = $cancelFn;
|
||||
}
|
||||
public function then(callable $onFulfilled = null, callable $onRejected = null)
|
||||
public function then(callable $onFulfilled = null, callable $onRejected = null) : \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
{
|
||||
if ($this->state === self::PENDING) {
|
||||
$p = new \WPMailSMTP\Vendor\GuzzleHttp\Promise\Promise(null, [$this, 'cancel']);
|
||||
@@ -43,11 +46,11 @@ class Promise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
$rejection = \WPMailSMTP\Vendor\GuzzleHttp\Promise\Create::rejectionFor($this->result);
|
||||
return $onRejected ? $rejection->then(null, $onRejected) : $rejection;
|
||||
}
|
||||
public function otherwise(callable $onRejected)
|
||||
public function otherwise(callable $onRejected) : \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
{
|
||||
return $this->then(null, $onRejected);
|
||||
}
|
||||
public function wait($unwrap = \true)
|
||||
public function wait(bool $unwrap = \true)
|
||||
{
|
||||
$this->waitIfPending();
|
||||
if ($this->result instanceof \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface) {
|
||||
@@ -61,11 +64,11 @@ class Promise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
throw \WPMailSMTP\Vendor\GuzzleHttp\Promise\Create::exceptionFor($this->result);
|
||||
}
|
||||
}
|
||||
public function getState()
|
||||
public function getState() : string
|
||||
{
|
||||
return $this->state;
|
||||
}
|
||||
public function cancel()
|
||||
public function cancel() : void
|
||||
{
|
||||
if ($this->state !== self::PENDING) {
|
||||
return;
|
||||
@@ -78,8 +81,6 @@ class Promise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
$fn();
|
||||
} catch (\Throwable $e) {
|
||||
$this->reject($e);
|
||||
} catch (\Exception $e) {
|
||||
$this->reject($e);
|
||||
}
|
||||
}
|
||||
// Reject the promise only if it wasn't rejected in a then callback.
|
||||
@@ -88,15 +89,15 @@ class Promise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
$this->reject(new \WPMailSMTP\Vendor\GuzzleHttp\Promise\CancellationException('Promise has been cancelled'));
|
||||
}
|
||||
}
|
||||
public function resolve($value)
|
||||
public function resolve($value) : void
|
||||
{
|
||||
$this->settle(self::FULFILLED, $value);
|
||||
}
|
||||
public function reject($reason)
|
||||
public function reject($reason) : void
|
||||
{
|
||||
$this->settle(self::REJECTED, $reason);
|
||||
}
|
||||
private function settle($state, $value)
|
||||
private function settle(string $state, $value) : void
|
||||
{
|
||||
if ($this->state !== self::PENDING) {
|
||||
// Ignore calls with the same resolution.
|
||||
@@ -123,7 +124,7 @@ class Promise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
if (!\is_object($value) || !\method_exists($value, 'then')) {
|
||||
$id = $state === self::FULFILLED ? 1 : 2;
|
||||
// It's a success, so resolve the handlers in the queue.
|
||||
\WPMailSMTP\Vendor\GuzzleHttp\Promise\Utils::queue()->add(static function () use($id, $value, $handlers) {
|
||||
\WPMailSMTP\Vendor\GuzzleHttp\Promise\Utils::queue()->add(static function () use($id, $value, $handlers) : void {
|
||||
foreach ($handlers as $handler) {
|
||||
self::callHandler($id, $value, $handler);
|
||||
}
|
||||
@@ -133,11 +134,11 @@ class Promise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
$value->handlers = \array_merge($value->handlers, $handlers);
|
||||
} else {
|
||||
// Resolve the handlers when the forwarded promise is resolved.
|
||||
$value->then(static function ($value) use($handlers) {
|
||||
$value->then(static function ($value) use($handlers) : void {
|
||||
foreach ($handlers as $handler) {
|
||||
self::callHandler(1, $value, $handler);
|
||||
}
|
||||
}, static function ($reason) use($handlers) {
|
||||
}, static function ($reason) use($handlers) : void {
|
||||
foreach ($handlers as $handler) {
|
||||
self::callHandler(2, $reason, $handler);
|
||||
}
|
||||
@@ -151,7 +152,7 @@ class Promise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
* @param mixed $value Value to pass to the callback.
|
||||
* @param array $handler Array of handler data (promise and callbacks).
|
||||
*/
|
||||
private static function callHandler($index, $value, array $handler)
|
||||
private static function callHandler(int $index, $value, array $handler) : void
|
||||
{
|
||||
/** @var PromiseInterface $promise */
|
||||
$promise = $handler[0];
|
||||
@@ -180,11 +181,9 @@ class Promise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
}
|
||||
} catch (\Throwable $reason) {
|
||||
$promise->reject($reason);
|
||||
} catch (\Exception $reason) {
|
||||
$promise->reject($reason);
|
||||
}
|
||||
}
|
||||
private function waitIfPending()
|
||||
private function waitIfPending() : void
|
||||
{
|
||||
if ($this->state !== self::PENDING) {
|
||||
return;
|
||||
@@ -202,13 +201,13 @@ class Promise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
$this->reject('Invoking the wait callback did not resolve the promise');
|
||||
}
|
||||
}
|
||||
private function invokeWaitFn()
|
||||
private function invokeWaitFn() : void
|
||||
{
|
||||
try {
|
||||
$wfn = $this->waitFn;
|
||||
$this->waitFn = null;
|
||||
$wfn(\true);
|
||||
} catch (\Exception $reason) {
|
||||
} catch (\Throwable $reason) {
|
||||
if ($this->state === self::PENDING) {
|
||||
// The promise has not been resolved yet, so reject the promise
|
||||
// with the exception.
|
||||
@@ -220,7 +219,7 @@ class Promise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
}
|
||||
}
|
||||
}
|
||||
private function invokeWaitList()
|
||||
private function invokeWaitList() : void
|
||||
{
|
||||
$waitList = $this->waitList;
|
||||
$this->waitList = null;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace WPMailSMTP\Vendor\GuzzleHttp\Promise;
|
||||
|
||||
/**
|
||||
@@ -9,23 +10,21 @@ namespace WPMailSMTP\Vendor\GuzzleHttp\Promise;
|
||||
* which registers callbacks to receive either a promise’s eventual value or
|
||||
* the reason why the promise cannot be fulfilled.
|
||||
*
|
||||
* @link https://promisesaplus.com/
|
||||
* @see https://promisesaplus.com/
|
||||
*/
|
||||
interface PromiseInterface
|
||||
{
|
||||
const PENDING = 'pending';
|
||||
const FULFILLED = 'fulfilled';
|
||||
const REJECTED = 'rejected';
|
||||
public const PENDING = 'pending';
|
||||
public const FULFILLED = 'fulfilled';
|
||||
public const REJECTED = 'rejected';
|
||||
/**
|
||||
* Appends fulfillment and rejection handlers to the promise, and returns
|
||||
* a new promise resolving to the return value of the called handler.
|
||||
*
|
||||
* @param callable $onFulfilled Invoked when the promise fulfills.
|
||||
* @param callable $onRejected Invoked when the promise is rejected.
|
||||
*
|
||||
* @return PromiseInterface
|
||||
*/
|
||||
public function then(callable $onFulfilled = null, callable $onRejected = null);
|
||||
public function then(callable $onFulfilled = null, callable $onRejected = null) : \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface;
|
||||
/**
|
||||
* Appends a rejection handler callback to the promise, and returns a new
|
||||
* promise resolving to the return value of the callback if it is called,
|
||||
@@ -33,19 +32,15 @@ interface PromiseInterface
|
||||
* fulfilled.
|
||||
*
|
||||
* @param callable $onRejected Invoked when the promise is rejected.
|
||||
*
|
||||
* @return PromiseInterface
|
||||
*/
|
||||
public function otherwise(callable $onRejected);
|
||||
public function otherwise(callable $onRejected) : \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface;
|
||||
/**
|
||||
* Get the state of the promise ("pending", "rejected", or "fulfilled").
|
||||
*
|
||||
* The three states can be checked against the constants defined on
|
||||
* PromiseInterface: PENDING, FULFILLED, and REJECTED.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getState();
|
||||
public function getState() : string;
|
||||
/**
|
||||
* Resolve the promise with the given value.
|
||||
*
|
||||
@@ -53,7 +48,7 @@ interface PromiseInterface
|
||||
*
|
||||
* @throws \RuntimeException if the promise is already resolved.
|
||||
*/
|
||||
public function resolve($value);
|
||||
public function resolve($value) : void;
|
||||
/**
|
||||
* Reject the promise with the given reason.
|
||||
*
|
||||
@@ -61,13 +56,13 @@ interface PromiseInterface
|
||||
*
|
||||
* @throws \RuntimeException if the promise is already resolved.
|
||||
*/
|
||||
public function reject($reason);
|
||||
public function reject($reason) : void;
|
||||
/**
|
||||
* Cancels the promise if possible.
|
||||
*
|
||||
* @link https://github.com/promises-aplus/cancellation-spec/issues/7
|
||||
* @see https://github.com/promises-aplus/cancellation-spec/issues/7
|
||||
*/
|
||||
public function cancel();
|
||||
public function cancel() : void;
|
||||
/**
|
||||
* Waits until the promise completes if possible.
|
||||
*
|
||||
@@ -76,12 +71,10 @@ interface PromiseInterface
|
||||
*
|
||||
* If the promise cannot be waited on, then the promise will be rejected.
|
||||
*
|
||||
* @param bool $unwrap
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \LogicException if the promise has no wait function or if the
|
||||
* promise does not settle after waiting.
|
||||
*/
|
||||
public function wait($unwrap = \true);
|
||||
public function wait(bool $unwrap = \true);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace WPMailSMTP\Vendor\GuzzleHttp\Promise;
|
||||
|
||||
/**
|
||||
@@ -9,8 +10,6 @@ interface PromisorInterface
|
||||
{
|
||||
/**
|
||||
* Returns a promise.
|
||||
*
|
||||
* @return PromiseInterface
|
||||
*/
|
||||
public function promise();
|
||||
public function promise() : \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace WPMailSMTP\Vendor\GuzzleHttp\Promise;
|
||||
|
||||
/**
|
||||
@@ -7,10 +8,15 @@ namespace WPMailSMTP\Vendor\GuzzleHttp\Promise;
|
||||
*
|
||||
* Thenning off of this promise will invoke the onRejected callback
|
||||
* immediately and ignore other callbacks.
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class RejectedPromise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
{
|
||||
private $reason;
|
||||
/**
|
||||
* @param mixed $reason
|
||||
*/
|
||||
public function __construct($reason)
|
||||
{
|
||||
if (\is_object($reason) && \method_exists($reason, 'then')) {
|
||||
@@ -18,7 +24,7 @@ class RejectedPromise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseIn
|
||||
}
|
||||
$this->reason = $reason;
|
||||
}
|
||||
public function then(callable $onFulfilled = null, callable $onRejected = null)
|
||||
public function then(callable $onFulfilled = null, callable $onRejected = null) : \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
{
|
||||
// If there's no onRejected callback then just return self.
|
||||
if (!$onRejected) {
|
||||
@@ -27,7 +33,7 @@ class RejectedPromise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseIn
|
||||
$queue = \WPMailSMTP\Vendor\GuzzleHttp\Promise\Utils::queue();
|
||||
$reason = $this->reason;
|
||||
$p = new \WPMailSMTP\Vendor\GuzzleHttp\Promise\Promise([$queue, 'run']);
|
||||
$queue->add(static function () use($p, $reason, $onRejected) {
|
||||
$queue->add(static function () use($p, $reason, $onRejected) : void {
|
||||
if (\WPMailSMTP\Vendor\GuzzleHttp\Promise\Is::pending($p)) {
|
||||
try {
|
||||
// Return a resolved promise if onRejected does not throw.
|
||||
@@ -35,40 +41,37 @@ class RejectedPromise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseIn
|
||||
} catch (\Throwable $e) {
|
||||
// onRejected threw, so return a rejected promise.
|
||||
$p->reject($e);
|
||||
} catch (\Exception $e) {
|
||||
// onRejected threw, so return a rejected promise.
|
||||
$p->reject($e);
|
||||
}
|
||||
}
|
||||
});
|
||||
return $p;
|
||||
}
|
||||
public function otherwise(callable $onRejected)
|
||||
public function otherwise(callable $onRejected) : \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
{
|
||||
return $this->then(null, $onRejected);
|
||||
}
|
||||
public function wait($unwrap = \true, $defaultDelivery = null)
|
||||
public function wait(bool $unwrap = \true)
|
||||
{
|
||||
if ($unwrap) {
|
||||
throw \WPMailSMTP\Vendor\GuzzleHttp\Promise\Create::exceptionFor($this->reason);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public function getState()
|
||||
public function getState() : string
|
||||
{
|
||||
return self::REJECTED;
|
||||
}
|
||||
public function resolve($value)
|
||||
public function resolve($value) : void
|
||||
{
|
||||
throw new \LogicException("Cannot resolve a rejected promise");
|
||||
throw new \LogicException('Cannot resolve a rejected promise');
|
||||
}
|
||||
public function reject($reason)
|
||||
public function reject($reason) : void
|
||||
{
|
||||
if ($reason !== $this->reason) {
|
||||
throw new \LogicException("Cannot reject a rejected promise");
|
||||
throw new \LogicException('Cannot reject a rejected promise');
|
||||
}
|
||||
}
|
||||
public function cancel()
|
||||
public function cancel() : void
|
||||
{
|
||||
// pass
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace WPMailSMTP\Vendor\GuzzleHttp\Promise;
|
||||
|
||||
/**
|
||||
@@ -12,10 +13,10 @@ class RejectionException extends \RuntimeException
|
||||
/** @var mixed Rejection reason. */
|
||||
private $reason;
|
||||
/**
|
||||
* @param mixed $reason Rejection reason.
|
||||
* @param string $description Optional description
|
||||
* @param mixed $reason Rejection reason.
|
||||
* @param string|null $description Optional description.
|
||||
*/
|
||||
public function __construct($reason, $description = null)
|
||||
public function __construct($reason, string $description = null)
|
||||
{
|
||||
$this->reason = $reason;
|
||||
$message = 'The promise was rejected';
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace WPMailSMTP\Vendor\GuzzleHttp\Promise;
|
||||
|
||||
/**
|
||||
@@ -10,15 +11,17 @@ namespace WPMailSMTP\Vendor\GuzzleHttp\Promise;
|
||||
* by calling the `run()` function of the global task queue in an event loop.
|
||||
*
|
||||
* GuzzleHttp\Promise\Utils::queue()->run();
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class TaskQueue implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\TaskQueueInterface
|
||||
{
|
||||
private $enableShutdown = \true;
|
||||
private $queue = [];
|
||||
public function __construct($withShutdown = \true)
|
||||
public function __construct(bool $withShutdown = \true)
|
||||
{
|
||||
if ($withShutdown) {
|
||||
\register_shutdown_function(function () {
|
||||
\register_shutdown_function(function () : void {
|
||||
if ($this->enableShutdown) {
|
||||
// Only run the tasks if an E_ERROR didn't occur.
|
||||
$err = \error_get_last();
|
||||
@@ -29,15 +32,15 @@ class TaskQueue implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\TaskQueueInterf
|
||||
});
|
||||
}
|
||||
}
|
||||
public function isEmpty()
|
||||
public function isEmpty() : bool
|
||||
{
|
||||
return !$this->queue;
|
||||
}
|
||||
public function add(callable $task)
|
||||
public function add(callable $task) : void
|
||||
{
|
||||
$this->queue[] = $task;
|
||||
}
|
||||
public function run()
|
||||
public function run() : void
|
||||
{
|
||||
while ($task = \array_shift($this->queue)) {
|
||||
/** @var callable $task */
|
||||
@@ -55,7 +58,7 @@ class TaskQueue implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\TaskQueueInterf
|
||||
*
|
||||
* Note: This shutdown will occur before any destructors are triggered.
|
||||
*/
|
||||
public function disableShutdown()
|
||||
public function disableShutdown() : void
|
||||
{
|
||||
$this->enableShutdown = \false;
|
||||
}
|
||||
|
||||
@@ -1,22 +1,21 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace WPMailSMTP\Vendor\GuzzleHttp\Promise;
|
||||
|
||||
interface TaskQueueInterface
|
||||
{
|
||||
/**
|
||||
* Returns true if the queue is empty.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEmpty();
|
||||
public function isEmpty() : bool;
|
||||
/**
|
||||
* Adds a task to the queue that will be executed the next time run is
|
||||
* called.
|
||||
*/
|
||||
public function add(callable $task);
|
||||
public function add(callable $task) : void;
|
||||
/**
|
||||
* Execute all of the pending task in the queue.
|
||||
*/
|
||||
public function run();
|
||||
public function run() : void;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace WPMailSMTP\Vendor\GuzzleHttp\Promise;
|
||||
|
||||
final class Utils
|
||||
@@ -17,11 +18,9 @@ final class Utils
|
||||
* }
|
||||
* </code>
|
||||
*
|
||||
* @param TaskQueueInterface $assign Optionally specify a new queue instance.
|
||||
*
|
||||
* @return TaskQueueInterface
|
||||
* @param TaskQueueInterface|null $assign Optionally specify a new queue instance.
|
||||
*/
|
||||
public static function queue(\WPMailSMTP\Vendor\GuzzleHttp\Promise\TaskQueueInterface $assign = null)
|
||||
public static function queue(\WPMailSMTP\Vendor\GuzzleHttp\Promise\TaskQueueInterface $assign = null) : \WPMailSMTP\Vendor\GuzzleHttp\Promise\TaskQueueInterface
|
||||
{
|
||||
static $queue;
|
||||
if ($assign) {
|
||||
@@ -36,22 +35,18 @@ final class Utils
|
||||
* returns a promise that is fulfilled or rejected with the result.
|
||||
*
|
||||
* @param callable $task Task function to run.
|
||||
*
|
||||
* @return PromiseInterface
|
||||
*/
|
||||
public static function task(callable $task)
|
||||
public static function task(callable $task) : \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
{
|
||||
$queue = self::queue();
|
||||
$promise = new \WPMailSMTP\Vendor\GuzzleHttp\Promise\Promise([$queue, 'run']);
|
||||
$queue->add(function () use($task, $promise) {
|
||||
$queue->add(function () use($task, $promise) : void {
|
||||
try {
|
||||
if (\WPMailSMTP\Vendor\GuzzleHttp\Promise\Is::pending($promise)) {
|
||||
$promise->resolve($task());
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
$promise->reject($e);
|
||||
} catch (\Exception $e) {
|
||||
$promise->reject($e);
|
||||
}
|
||||
});
|
||||
return $promise;
|
||||
@@ -67,10 +62,8 @@ final class Utils
|
||||
* key mapping to the rejection reason of the promise.
|
||||
*
|
||||
* @param PromiseInterface $promise Promise or value.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function inspect(\WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface $promise)
|
||||
public static function inspect(\WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface $promise) : array
|
||||
{
|
||||
try {
|
||||
return ['state' => \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface::FULFILLED, 'value' => $promise->wait()];
|
||||
@@ -78,8 +71,6 @@ final class Utils
|
||||
return ['state' => \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface::REJECTED, 'reason' => $e->getReason()];
|
||||
} catch (\Throwable $e) {
|
||||
return ['state' => \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface::REJECTED, 'reason' => $e];
|
||||
} catch (\Exception $e) {
|
||||
return ['state' => \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface::REJECTED, 'reason' => $e];
|
||||
}
|
||||
}
|
||||
/**
|
||||
@@ -91,10 +82,8 @@ final class Utils
|
||||
* @see inspect for the inspection state array format.
|
||||
*
|
||||
* @param PromiseInterface[] $promises Traversable of promises to wait upon.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function inspectAll($promises)
|
||||
public static function inspectAll($promises) : array
|
||||
{
|
||||
$results = [];
|
||||
foreach ($promises as $key => $promise) {
|
||||
@@ -111,12 +100,9 @@ final class Utils
|
||||
*
|
||||
* @param iterable<PromiseInterface> $promises Iterable of PromiseInterface objects to wait on.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws \Exception on error
|
||||
* @throws \Throwable on error in PHP >=7
|
||||
* @throws \Throwable on error
|
||||
*/
|
||||
public static function unwrap($promises)
|
||||
public static function unwrap($promises) : array
|
||||
{
|
||||
$results = [];
|
||||
foreach ($promises as $key => $promise) {
|
||||
@@ -134,15 +120,13 @@ final class Utils
|
||||
*
|
||||
* @param mixed $promises Promises or values.
|
||||
* @param bool $recursive If true, resolves new promises that might have been added to the stack during its own resolution.
|
||||
*
|
||||
* @return PromiseInterface
|
||||
*/
|
||||
public static function all($promises, $recursive = \false)
|
||||
public static function all($promises, bool $recursive = \false) : \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
{
|
||||
$results = [];
|
||||
$promise = \WPMailSMTP\Vendor\GuzzleHttp\Promise\Each::of($promises, function ($value, $idx) use(&$results) {
|
||||
$promise = \WPMailSMTP\Vendor\GuzzleHttp\Promise\Each::of($promises, function ($value, $idx) use(&$results) : void {
|
||||
$results[$idx] = $value;
|
||||
}, function ($reason, $idx, \WPMailSMTP\Vendor\GuzzleHttp\Promise\Promise $aggregate) {
|
||||
}, function ($reason, $idx, \WPMailSMTP\Vendor\GuzzleHttp\Promise\Promise $aggregate) : void {
|
||||
$aggregate->reject($reason);
|
||||
})->then(function () use(&$results) {
|
||||
\ksort($results);
|
||||
@@ -173,14 +157,12 @@ final class Utils
|
||||
*
|
||||
* @param int $count Total number of promises.
|
||||
* @param mixed $promises Promises or values.
|
||||
*
|
||||
* @return PromiseInterface
|
||||
*/
|
||||
public static function some($count, $promises)
|
||||
public static function some(int $count, $promises) : \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
{
|
||||
$results = [];
|
||||
$rejections = [];
|
||||
return \WPMailSMTP\Vendor\GuzzleHttp\Promise\Each::of($promises, function ($value, $idx, \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface $p) use(&$results, $count) {
|
||||
return \WPMailSMTP\Vendor\GuzzleHttp\Promise\Each::of($promises, function ($value, $idx, \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface $p) use(&$results, $count) : void {
|
||||
if (\WPMailSMTP\Vendor\GuzzleHttp\Promise\Is::settled($p)) {
|
||||
return;
|
||||
}
|
||||
@@ -188,7 +170,7 @@ final class Utils
|
||||
if (\count($results) >= $count) {
|
||||
$p->resolve(null);
|
||||
}
|
||||
}, function ($reason) use(&$rejections) {
|
||||
}, function ($reason) use(&$rejections) : void {
|
||||
$rejections[] = $reason;
|
||||
})->then(function () use(&$results, &$rejections, $count) {
|
||||
if (\count($results) !== $count) {
|
||||
@@ -203,10 +185,8 @@ final class Utils
|
||||
* fulfillment value is not an array of 1 but the value directly.
|
||||
*
|
||||
* @param mixed $promises Promises or values.
|
||||
*
|
||||
* @return PromiseInterface
|
||||
*/
|
||||
public static function any($promises)
|
||||
public static function any($promises) : \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
{
|
||||
return self::some(1, $promises)->then(function ($values) {
|
||||
return $values[0];
|
||||
@@ -221,15 +201,13 @@ final class Utils
|
||||
* @see inspect for the inspection state array format.
|
||||
*
|
||||
* @param mixed $promises Promises or values.
|
||||
*
|
||||
* @return PromiseInterface
|
||||
*/
|
||||
public static function settle($promises)
|
||||
public static function settle($promises) : \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
{
|
||||
$results = [];
|
||||
return \WPMailSMTP\Vendor\GuzzleHttp\Promise\Each::of($promises, function ($value, $idx) use(&$results) {
|
||||
return \WPMailSMTP\Vendor\GuzzleHttp\Promise\Each::of($promises, function ($value, $idx) use(&$results) : void {
|
||||
$results[$idx] = ['state' => \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface::FULFILLED, 'value' => $value];
|
||||
}, function ($reason, $idx) use(&$results) {
|
||||
}, function ($reason, $idx) use(&$results) : void {
|
||||
$results[$idx] = ['state' => \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface::REJECTED, 'reason' => $reason];
|
||||
})->then(function () use(&$results) {
|
||||
\ksort($results);
|
||||
|
||||
@@ -1,334 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Vendor\GuzzleHttp\Promise;
|
||||
|
||||
/**
|
||||
* Get the global task queue used for promise resolution.
|
||||
*
|
||||
* This task queue MUST be run in an event loop in order for promises to be
|
||||
* settled asynchronously. It will be automatically run when synchronously
|
||||
* waiting on a promise.
|
||||
*
|
||||
* <code>
|
||||
* while ($eventLoop->isRunning()) {
|
||||
* GuzzleHttp\Promise\queue()->run();
|
||||
* }
|
||||
* </code>
|
||||
*
|
||||
* @param TaskQueueInterface $assign Optionally specify a new queue instance.
|
||||
*
|
||||
* @return TaskQueueInterface
|
||||
*
|
||||
* @deprecated queue will be removed in guzzlehttp/promises:2.0. Use Utils::queue instead.
|
||||
*/
|
||||
function queue(\WPMailSMTP\Vendor\GuzzleHttp\Promise\TaskQueueInterface $assign = null)
|
||||
{
|
||||
return \WPMailSMTP\Vendor\GuzzleHttp\Promise\Utils::queue($assign);
|
||||
}
|
||||
/**
|
||||
* Adds a function to run in the task queue when it is next `run()` and returns
|
||||
* a promise that is fulfilled or rejected with the result.
|
||||
*
|
||||
* @param callable $task Task function to run.
|
||||
*
|
||||
* @return PromiseInterface
|
||||
*
|
||||
* @deprecated task will be removed in guzzlehttp/promises:2.0. Use Utils::task instead.
|
||||
*/
|
||||
function task(callable $task)
|
||||
{
|
||||
return \WPMailSMTP\Vendor\GuzzleHttp\Promise\Utils::task($task);
|
||||
}
|
||||
/**
|
||||
* Creates a promise for a value if the value is not a promise.
|
||||
*
|
||||
* @param mixed $value Promise or value.
|
||||
*
|
||||
* @return PromiseInterface
|
||||
*
|
||||
* @deprecated promise_for will be removed in guzzlehttp/promises:2.0. Use Create::promiseFor instead.
|
||||
*/
|
||||
function promise_for($value)
|
||||
{
|
||||
return \WPMailSMTP\Vendor\GuzzleHttp\Promise\Create::promiseFor($value);
|
||||
}
|
||||
/**
|
||||
* Creates a rejected promise for a reason if the reason is not a promise. If
|
||||
* the provided reason is a promise, then it is returned as-is.
|
||||
*
|
||||
* @param mixed $reason Promise or reason.
|
||||
*
|
||||
* @return PromiseInterface
|
||||
*
|
||||
* @deprecated rejection_for will be removed in guzzlehttp/promises:2.0. Use Create::rejectionFor instead.
|
||||
*/
|
||||
function rejection_for($reason)
|
||||
{
|
||||
return \WPMailSMTP\Vendor\GuzzleHttp\Promise\Create::rejectionFor($reason);
|
||||
}
|
||||
/**
|
||||
* Create an exception for a rejected promise value.
|
||||
*
|
||||
* @param mixed $reason
|
||||
*
|
||||
* @return \Exception|\Throwable
|
||||
*
|
||||
* @deprecated exception_for will be removed in guzzlehttp/promises:2.0. Use Create::exceptionFor instead.
|
||||
*/
|
||||
function exception_for($reason)
|
||||
{
|
||||
return \WPMailSMTP\Vendor\GuzzleHttp\Promise\Create::exceptionFor($reason);
|
||||
}
|
||||
/**
|
||||
* Returns an iterator for the given value.
|
||||
*
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return \Iterator
|
||||
*
|
||||
* @deprecated iter_for will be removed in guzzlehttp/promises:2.0. Use Create::iterFor instead.
|
||||
*/
|
||||
function iter_for($value)
|
||||
{
|
||||
return \WPMailSMTP\Vendor\GuzzleHttp\Promise\Create::iterFor($value);
|
||||
}
|
||||
/**
|
||||
* Synchronously waits on a promise to resolve and returns an inspection state
|
||||
* array.
|
||||
*
|
||||
* Returns a state associative array containing a "state" key mapping to a
|
||||
* valid promise state. If the state of the promise is "fulfilled", the array
|
||||
* will contain a "value" key mapping to the fulfilled value of the promise. If
|
||||
* the promise is rejected, the array will contain a "reason" key mapping to
|
||||
* the rejection reason of the promise.
|
||||
*
|
||||
* @param PromiseInterface $promise Promise or value.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @deprecated inspect will be removed in guzzlehttp/promises:2.0. Use Utils::inspect instead.
|
||||
*/
|
||||
function inspect(\WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface $promise)
|
||||
{
|
||||
return \WPMailSMTP\Vendor\GuzzleHttp\Promise\Utils::inspect($promise);
|
||||
}
|
||||
/**
|
||||
* Waits on all of the provided promises, but does not unwrap rejected promises
|
||||
* as thrown exception.
|
||||
*
|
||||
* Returns an array of inspection state arrays.
|
||||
*
|
||||
* @see inspect for the inspection state array format.
|
||||
*
|
||||
* @param PromiseInterface[] $promises Traversable of promises to wait upon.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @deprecated inspect will be removed in guzzlehttp/promises:2.0. Use Utils::inspectAll instead.
|
||||
*/
|
||||
function inspect_all($promises)
|
||||
{
|
||||
return \WPMailSMTP\Vendor\GuzzleHttp\Promise\Utils::inspectAll($promises);
|
||||
}
|
||||
/**
|
||||
* Waits on all of the provided promises and returns the fulfilled values.
|
||||
*
|
||||
* Returns an array that contains the value of each promise (in the same order
|
||||
* the promises were provided). An exception is thrown if any of the promises
|
||||
* are rejected.
|
||||
*
|
||||
* @param iterable<PromiseInterface> $promises Iterable of PromiseInterface objects to wait on.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws \Exception on error
|
||||
* @throws \Throwable on error in PHP >=7
|
||||
*
|
||||
* @deprecated unwrap will be removed in guzzlehttp/promises:2.0. Use Utils::unwrap instead.
|
||||
*/
|
||||
function unwrap($promises)
|
||||
{
|
||||
return \WPMailSMTP\Vendor\GuzzleHttp\Promise\Utils::unwrap($promises);
|
||||
}
|
||||
/**
|
||||
* Given an array of promises, return a promise that is fulfilled when all the
|
||||
* items in the array are fulfilled.
|
||||
*
|
||||
* The promise's fulfillment value is an array with fulfillment values at
|
||||
* respective positions to the original array. If any promise in the array
|
||||
* rejects, the returned promise is rejected with the rejection reason.
|
||||
*
|
||||
* @param mixed $promises Promises or values.
|
||||
* @param bool $recursive If true, resolves new promises that might have been added to the stack during its own resolution.
|
||||
*
|
||||
* @return PromiseInterface
|
||||
*
|
||||
* @deprecated all will be removed in guzzlehttp/promises:2.0. Use Utils::all instead.
|
||||
*/
|
||||
function all($promises, $recursive = \false)
|
||||
{
|
||||
return \WPMailSMTP\Vendor\GuzzleHttp\Promise\Utils::all($promises, $recursive);
|
||||
}
|
||||
/**
|
||||
* Initiate a competitive race between multiple promises or values (values will
|
||||
* become immediately fulfilled promises).
|
||||
*
|
||||
* When count amount of promises have been fulfilled, the returned promise is
|
||||
* fulfilled with an array that contains the fulfillment values of the winners
|
||||
* in order of resolution.
|
||||
*
|
||||
* This promise is rejected with a {@see AggregateException} if the number of
|
||||
* fulfilled promises is less than the desired $count.
|
||||
*
|
||||
* @param int $count Total number of promises.
|
||||
* @param mixed $promises Promises or values.
|
||||
*
|
||||
* @return PromiseInterface
|
||||
*
|
||||
* @deprecated some will be removed in guzzlehttp/promises:2.0. Use Utils::some instead.
|
||||
*/
|
||||
function some($count, $promises)
|
||||
{
|
||||
return \WPMailSMTP\Vendor\GuzzleHttp\Promise\Utils::some($count, $promises);
|
||||
}
|
||||
/**
|
||||
* Like some(), with 1 as count. However, if the promise fulfills, the
|
||||
* fulfillment value is not an array of 1 but the value directly.
|
||||
*
|
||||
* @param mixed $promises Promises or values.
|
||||
*
|
||||
* @return PromiseInterface
|
||||
*
|
||||
* @deprecated any will be removed in guzzlehttp/promises:2.0. Use Utils::any instead.
|
||||
*/
|
||||
function any($promises)
|
||||
{
|
||||
return \WPMailSMTP\Vendor\GuzzleHttp\Promise\Utils::any($promises);
|
||||
}
|
||||
/**
|
||||
* Returns a promise that is fulfilled when all of the provided promises have
|
||||
* been fulfilled or rejected.
|
||||
*
|
||||
* The returned promise is fulfilled with an array of inspection state arrays.
|
||||
*
|
||||
* @see inspect for the inspection state array format.
|
||||
*
|
||||
* @param mixed $promises Promises or values.
|
||||
*
|
||||
* @return PromiseInterface
|
||||
*
|
||||
* @deprecated settle will be removed in guzzlehttp/promises:2.0. Use Utils::settle instead.
|
||||
*/
|
||||
function settle($promises)
|
||||
{
|
||||
return \WPMailSMTP\Vendor\GuzzleHttp\Promise\Utils::settle($promises);
|
||||
}
|
||||
/**
|
||||
* Given an iterator that yields promises or values, returns a promise that is
|
||||
* fulfilled with a null value when the iterator has been consumed or the
|
||||
* aggregate promise has been fulfilled or rejected.
|
||||
*
|
||||
* $onFulfilled is a function that accepts the fulfilled value, iterator index,
|
||||
* and the aggregate promise. The callback can invoke any necessary side
|
||||
* effects and choose to resolve or reject the aggregate if needed.
|
||||
*
|
||||
* $onRejected is a function that accepts the rejection reason, iterator index,
|
||||
* and the aggregate promise. The callback can invoke any necessary side
|
||||
* effects and choose to resolve or reject the aggregate if needed.
|
||||
*
|
||||
* @param mixed $iterable Iterator or array to iterate over.
|
||||
* @param callable $onFulfilled
|
||||
* @param callable $onRejected
|
||||
*
|
||||
* @return PromiseInterface
|
||||
*
|
||||
* @deprecated each will be removed in guzzlehttp/promises:2.0. Use Each::of instead.
|
||||
*/
|
||||
function each($iterable, callable $onFulfilled = null, callable $onRejected = null)
|
||||
{
|
||||
return \WPMailSMTP\Vendor\GuzzleHttp\Promise\Each::of($iterable, $onFulfilled, $onRejected);
|
||||
}
|
||||
/**
|
||||
* Like each, but only allows a certain number of outstanding promises at any
|
||||
* given time.
|
||||
*
|
||||
* $concurrency may be an integer or a function that accepts the number of
|
||||
* pending promises and returns a numeric concurrency limit value to allow for
|
||||
* dynamic a concurrency size.
|
||||
*
|
||||
* @param mixed $iterable
|
||||
* @param int|callable $concurrency
|
||||
* @param callable $onFulfilled
|
||||
* @param callable $onRejected
|
||||
*
|
||||
* @return PromiseInterface
|
||||
*
|
||||
* @deprecated each_limit will be removed in guzzlehttp/promises:2.0. Use Each::ofLimit instead.
|
||||
*/
|
||||
function each_limit($iterable, $concurrency, callable $onFulfilled = null, callable $onRejected = null)
|
||||
{
|
||||
return \WPMailSMTP\Vendor\GuzzleHttp\Promise\Each::ofLimit($iterable, $concurrency, $onFulfilled, $onRejected);
|
||||
}
|
||||
/**
|
||||
* Like each_limit, but ensures that no promise in the given $iterable argument
|
||||
* is rejected. If any promise is rejected, then the aggregate promise is
|
||||
* rejected with the encountered rejection.
|
||||
*
|
||||
* @param mixed $iterable
|
||||
* @param int|callable $concurrency
|
||||
* @param callable $onFulfilled
|
||||
*
|
||||
* @return PromiseInterface
|
||||
*
|
||||
* @deprecated each_limit_all will be removed in guzzlehttp/promises:2.0. Use Each::ofLimitAll instead.
|
||||
*/
|
||||
function each_limit_all($iterable, $concurrency, callable $onFulfilled = null)
|
||||
{
|
||||
return \WPMailSMTP\Vendor\GuzzleHttp\Promise\Each::ofLimitAll($iterable, $concurrency, $onFulfilled);
|
||||
}
|
||||
/**
|
||||
* Returns true if a promise is fulfilled.
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @deprecated is_fulfilled will be removed in guzzlehttp/promises:2.0. Use Is::fulfilled instead.
|
||||
*/
|
||||
function is_fulfilled(\WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface $promise)
|
||||
{
|
||||
return \WPMailSMTP\Vendor\GuzzleHttp\Promise\Is::fulfilled($promise);
|
||||
}
|
||||
/**
|
||||
* Returns true if a promise is rejected.
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @deprecated is_rejected will be removed in guzzlehttp/promises:2.0. Use Is::rejected instead.
|
||||
*/
|
||||
function is_rejected(\WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface $promise)
|
||||
{
|
||||
return \WPMailSMTP\Vendor\GuzzleHttp\Promise\Is::rejected($promise);
|
||||
}
|
||||
/**
|
||||
* Returns true if a promise is fulfilled or rejected.
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @deprecated is_settled will be removed in guzzlehttp/promises:2.0. Use Is::settled instead.
|
||||
*/
|
||||
function is_settled(\WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface $promise)
|
||||
{
|
||||
return \WPMailSMTP\Vendor\GuzzleHttp\Promise\Is::settled($promise);
|
||||
}
|
||||
/**
|
||||
* Create a new coroutine.
|
||||
*
|
||||
* @see Coroutine
|
||||
*
|
||||
* @return PromiseInterface
|
||||
*
|
||||
* @deprecated coroutine will be removed in guzzlehttp/promises:2.0. Use Coroutine::of instead.
|
||||
*/
|
||||
function coroutine(callable $generatorFn)
|
||||
{
|
||||
return \WPMailSMTP\Vendor\GuzzleHttp\Promise\Coroutine::of($generatorFn);
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Vendor;
|
||||
|
||||
// Don't redefine the functions if included multiple times.
|
||||
if (!\function_exists('WPMailSMTP\\Vendor\\GuzzleHttp\\Promise\\promise_for')) {
|
||||
require __DIR__ . '/functions.php';
|
||||
}
|
||||
@@ -42,7 +42,7 @@ final class FnStream implements \WPMailSMTP\Vendor\Psr\Http\Message\StreamInterf
|
||||
public function __destruct()
|
||||
{
|
||||
if (isset($this->_fn_close)) {
|
||||
\call_user_func($this->_fn_close);
|
||||
($this->_fn_close)();
|
||||
}
|
||||
}
|
||||
/**
|
||||
@@ -77,7 +77,8 @@ final class FnStream implements \WPMailSMTP\Vendor\Psr\Http\Message\StreamInterf
|
||||
public function __toString() : string
|
||||
{
|
||||
try {
|
||||
return \call_user_func($this->_fn___toString);
|
||||
/** @var string */
|
||||
return ($this->_fn___toString)();
|
||||
} catch (\Throwable $e) {
|
||||
if (\PHP_VERSION_ID >= 70400) {
|
||||
throw $e;
|
||||
@@ -88,61 +89,61 @@ final class FnStream implements \WPMailSMTP\Vendor\Psr\Http\Message\StreamInterf
|
||||
}
|
||||
public function close() : void
|
||||
{
|
||||
\call_user_func($this->_fn_close);
|
||||
($this->_fn_close)();
|
||||
}
|
||||
public function detach()
|
||||
{
|
||||
return \call_user_func($this->_fn_detach);
|
||||
return ($this->_fn_detach)();
|
||||
}
|
||||
public function getSize() : ?int
|
||||
{
|
||||
return \call_user_func($this->_fn_getSize);
|
||||
return ($this->_fn_getSize)();
|
||||
}
|
||||
public function tell() : int
|
||||
{
|
||||
return \call_user_func($this->_fn_tell);
|
||||
return ($this->_fn_tell)();
|
||||
}
|
||||
public function eof() : bool
|
||||
{
|
||||
return \call_user_func($this->_fn_eof);
|
||||
return ($this->_fn_eof)();
|
||||
}
|
||||
public function isSeekable() : bool
|
||||
{
|
||||
return \call_user_func($this->_fn_isSeekable);
|
||||
return ($this->_fn_isSeekable)();
|
||||
}
|
||||
public function rewind() : void
|
||||
{
|
||||
\call_user_func($this->_fn_rewind);
|
||||
($this->_fn_rewind)();
|
||||
}
|
||||
public function seek($offset, $whence = \SEEK_SET) : void
|
||||
{
|
||||
\call_user_func($this->_fn_seek, $offset, $whence);
|
||||
($this->_fn_seek)($offset, $whence);
|
||||
}
|
||||
public function isWritable() : bool
|
||||
{
|
||||
return \call_user_func($this->_fn_isWritable);
|
||||
return ($this->_fn_isWritable)();
|
||||
}
|
||||
public function write($string) : int
|
||||
{
|
||||
return \call_user_func($this->_fn_write, $string);
|
||||
return ($this->_fn_write)($string);
|
||||
}
|
||||
public function isReadable() : bool
|
||||
{
|
||||
return \call_user_func($this->_fn_isReadable);
|
||||
return ($this->_fn_isReadable)();
|
||||
}
|
||||
public function read($length) : string
|
||||
{
|
||||
return \call_user_func($this->_fn_read, $length);
|
||||
return ($this->_fn_read)($length);
|
||||
}
|
||||
public function getContents() : string
|
||||
{
|
||||
return \call_user_func($this->_fn_getContents);
|
||||
return ($this->_fn_getContents)();
|
||||
}
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getMetadata($key = null)
|
||||
{
|
||||
return \call_user_func($this->_fn_getMetadata, $key);
|
||||
return ($this->_fn_getMetadata)($key);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ final class Header
|
||||
foreach ((array) $header as $value) {
|
||||
foreach (self::splitList($value) as $val) {
|
||||
$part = [];
|
||||
foreach (\preg_split('/;(?=([^"]*"[^"]*")*[^"]*$)/', $val) as $kvp) {
|
||||
foreach (\preg_split('/;(?=([^"]*"[^"]*")*[^"]*$)/', $val) ?: [] as $kvp) {
|
||||
if (\preg_match_all('/<[^>]+>|[^=]+/', $kvp, $matches)) {
|
||||
$m = $matches[0];
|
||||
if (isset($m[1])) {
|
||||
|
||||
@@ -11,9 +11,9 @@ use WPMailSMTP\Vendor\Psr\Http\Message\StreamInterface;
|
||||
* then appends the zlib.inflate filter. The stream is then converted back
|
||||
* to a Guzzle stream resource to be used as a Guzzle stream.
|
||||
*
|
||||
* @see http://tools.ietf.org/html/rfc1950
|
||||
* @see http://tools.ietf.org/html/rfc1952
|
||||
* @see http://php.net/manual/en/filters.compression.php
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc1950
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc1952
|
||||
* @see https://www.php.net/manual/en/filters.compression.php
|
||||
*/
|
||||
final class InflateStream implements \WPMailSMTP\Vendor\Psr\Http\Message\StreamInterface
|
||||
{
|
||||
@@ -24,7 +24,7 @@ final class InflateStream implements \WPMailSMTP\Vendor\Psr\Http\Message\StreamI
|
||||
{
|
||||
$resource = \WPMailSMTP\Vendor\GuzzleHttp\Psr7\StreamWrapper::getResource($stream);
|
||||
// Specify window=15+32, so zlib will use header detection to both gzip (with header) and zlib data
|
||||
// See http://www.zlib.net/manual.html#Advanced definition of inflateInit2
|
||||
// See https://www.zlib.net/manual.html#Advanced definition of inflateInit2
|
||||
// "Add 32 to windowBits to enable zlib and gzip decoding with automatic header detection"
|
||||
// Default window size is 15.
|
||||
\stream_filter_append($resource, 'zlib.inflate', \STREAM_FILTER_READ, ['window' => 15 + 32]);
|
||||
|
||||
@@ -119,7 +119,7 @@ final class Message
|
||||
$count = \preg_match_all(\WPMailSMTP\Vendor\GuzzleHttp\Psr7\Rfc7230::HEADER_REGEX, $rawHeaders, $headerLines, \PREG_SET_ORDER);
|
||||
// If these aren't the same, then one line didn't match and there's an invalid header.
|
||||
if ($count !== \substr_count($rawHeaders, "\n")) {
|
||||
// Folding is deprecated, see https://tools.ietf.org/html/rfc7230#section-3.2.4
|
||||
// Folding is deprecated, see https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.4
|
||||
if (\preg_match(\WPMailSMTP\Vendor\GuzzleHttp\Psr7\Rfc7230::HEADER_FOLD_REGEX, $rawHeaders)) {
|
||||
throw new \InvalidArgumentException('Invalid header syntax: Obsolete line folding');
|
||||
}
|
||||
@@ -177,9 +177,9 @@ final class Message
|
||||
public static function parseResponse(string $message) : \WPMailSMTP\Vendor\Psr\Http\Message\ResponseInterface
|
||||
{
|
||||
$data = self::parseMessage($message);
|
||||
// According to https://tools.ietf.org/html/rfc7230#section-3.1.2 the space
|
||||
// between status-code and reason-phrase is required. But browsers accept
|
||||
// responses without space and reason as well.
|
||||
// According to https://datatracker.ietf.org/doc/html/rfc7230#section-3.1.2
|
||||
// the space between status-code and reason-phrase is required. But
|
||||
// browsers accept responses without space and reason as well.
|
||||
if (!\preg_match('/^HTTP\\/.* [0-9]{3}( .*|$)/', $data['start-line'])) {
|
||||
throw new \InvalidArgumentException('Invalid response string: ' . $data['start-line']);
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ trait MessageTrait
|
||||
return $new;
|
||||
}
|
||||
/**
|
||||
* @param array<string|int, string|string[]> $headers
|
||||
* @param (string|string[])[] $headers
|
||||
*/
|
||||
private function setHeaders(array $headers) : void
|
||||
{
|
||||
@@ -155,7 +155,7 @@ trait MessageTrait
|
||||
*
|
||||
* @return string[] Trimmed header values
|
||||
*
|
||||
* @see https://tools.ietf.org/html/rfc7230#section-3.2.4
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.4
|
||||
*/
|
||||
private function trimAndValidateHeaderValues(array $values) : array
|
||||
{
|
||||
@@ -169,7 +169,7 @@ trait MessageTrait
|
||||
}, \array_values($values));
|
||||
}
|
||||
/**
|
||||
* @see https://tools.ietf.org/html/rfc7230#section-3.2
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc7230#section-3.2
|
||||
*
|
||||
* @param mixed $header
|
||||
*/
|
||||
@@ -183,7 +183,7 @@ trait MessageTrait
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @see https://tools.ietf.org/html/rfc7230#section-3.2
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc7230#section-3.2
|
||||
*
|
||||
* field-value = *( field-content / obs-fold )
|
||||
* field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]
|
||||
|
||||
@@ -43,7 +43,7 @@ final class MultipartStream implements \WPMailSMTP\Vendor\Psr\Http\Message\Strea
|
||||
/**
|
||||
* Get the headers needed before transferring the content of a POST file
|
||||
*
|
||||
* @param array<string, string> $headers
|
||||
* @param string[] $headers
|
||||
*/
|
||||
private function getHeaders(array $headers) : string
|
||||
{
|
||||
@@ -88,32 +88,40 @@ final class MultipartStream implements \WPMailSMTP\Vendor\Psr\Http\Message\Strea
|
||||
$stream->addStream($body);
|
||||
$stream->addStream(\WPMailSMTP\Vendor\GuzzleHttp\Psr7\Utils::streamFor("\r\n"));
|
||||
}
|
||||
/**
|
||||
* @param string[] $headers
|
||||
*
|
||||
* @return array{0: StreamInterface, 1: string[]}
|
||||
*/
|
||||
private function createElement(string $name, \WPMailSMTP\Vendor\Psr\Http\Message\StreamInterface $stream, ?string $filename, array $headers) : array
|
||||
{
|
||||
// Set a default content-disposition header if one was no provided
|
||||
$disposition = $this->getHeader($headers, 'content-disposition');
|
||||
$disposition = self::getHeader($headers, 'content-disposition');
|
||||
if (!$disposition) {
|
||||
$headers['Content-Disposition'] = $filename === '0' || $filename ? \sprintf('form-data; name="%s"; filename="%s"', $name, \basename($filename)) : "form-data; name=\"{$name}\"";
|
||||
}
|
||||
// Set a default content-length header if one was no provided
|
||||
$length = $this->getHeader($headers, 'content-length');
|
||||
$length = self::getHeader($headers, 'content-length');
|
||||
if (!$length) {
|
||||
if ($length = $stream->getSize()) {
|
||||
$headers['Content-Length'] = (string) $length;
|
||||
}
|
||||
}
|
||||
// Set a default Content-Type if one was not supplied
|
||||
$type = $this->getHeader($headers, 'content-type');
|
||||
$type = self::getHeader($headers, 'content-type');
|
||||
if (!$type && ($filename === '0' || $filename)) {
|
||||
$headers['Content-Type'] = \WPMailSMTP\Vendor\GuzzleHttp\Psr7\MimeType::fromFilename($filename) ?? 'application/octet-stream';
|
||||
}
|
||||
return [$stream, $headers];
|
||||
}
|
||||
private function getHeader(array $headers, string $key)
|
||||
/**
|
||||
* @param string[] $headers
|
||||
*/
|
||||
private static function getHeader(array $headers, string $key) : ?string
|
||||
{
|
||||
$lowercaseHeader = \strtolower($key);
|
||||
foreach ($headers as $k => $v) {
|
||||
if (\strtolower($k) === $lowercaseHeader) {
|
||||
if (\strtolower((string) $k) === $lowercaseHeader) {
|
||||
return $v;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ use WPMailSMTP\Vendor\Psr\Http\Message\StreamInterface;
|
||||
*/
|
||||
final class PumpStream implements \WPMailSMTP\Vendor\Psr\Http\Message\StreamInterface
|
||||
{
|
||||
/** @var callable|null */
|
||||
/** @var callable(int): (string|false|null)|null */
|
||||
private $source;
|
||||
/** @var int|null */
|
||||
private $size;
|
||||
@@ -134,9 +134,9 @@ final class PumpStream implements \WPMailSMTP\Vendor\Psr\Http\Message\StreamInte
|
||||
}
|
||||
private function pump(int $length) : void
|
||||
{
|
||||
if ($this->source) {
|
||||
if ($this->source !== null) {
|
||||
do {
|
||||
$data = \call_user_func($this->source, $length);
|
||||
$data = ($this->source)($length);
|
||||
if ($data === \false || $data === null) {
|
||||
$this->source = null;
|
||||
return;
|
||||
|
||||
@@ -22,7 +22,7 @@ class Request implements \WPMailSMTP\Vendor\Psr\Http\Message\RequestInterface
|
||||
/**
|
||||
* @param string $method HTTP method
|
||||
* @param string|UriInterface $uri URI
|
||||
* @param array<string, string|string[]> $headers Request headers
|
||||
* @param (string|string[])[] $headers Request headers
|
||||
* @param string|resource|StreamInterface|null $body Request body
|
||||
* @param string $version Protocol version
|
||||
*/
|
||||
@@ -109,7 +109,7 @@ class Request implements \WPMailSMTP\Vendor\Psr\Http\Message\RequestInterface
|
||||
$this->headerNames['host'] = 'Host';
|
||||
}
|
||||
// Ensure Host is the first header.
|
||||
// See: http://tools.ietf.org/html/rfc7230#section-5.4
|
||||
// See: https://datatracker.ietf.org/doc/html/rfc7230#section-5.4
|
||||
$this->headers = [$header => [$host]] + $this->headers;
|
||||
}
|
||||
/**
|
||||
|
||||
@@ -19,7 +19,7 @@ class Response implements \WPMailSMTP\Vendor\Psr\Http\Message\ResponseInterface
|
||||
private $statusCode;
|
||||
/**
|
||||
* @param int $status Status code
|
||||
* @param array<string, string|string[]> $headers Response headers
|
||||
* @param (string|string[])[] $headers Response headers
|
||||
* @param string|resource|StreamInterface|null $body Response body
|
||||
* @param string $version Protocol version
|
||||
* @param string|null $reason Reason phrase (when empty a default will be used based on the status code)
|
||||
|
||||
@@ -51,7 +51,7 @@ class ServerRequest extends \WPMailSMTP\Vendor\GuzzleHttp\Psr7\Request implement
|
||||
/**
|
||||
* @param string $method HTTP method
|
||||
* @param string|UriInterface $uri URI
|
||||
* @param array<string, string|string[]> $headers Request headers
|
||||
* @param (string|string[])[] $headers Request headers
|
||||
* @param string|resource|StreamInterface|null $body Request body
|
||||
* @param string $version Protocol version
|
||||
* @param array $serverParams Typically the $_SERVER superglobal
|
||||
|
||||
@@ -10,8 +10,8 @@ use WPMailSMTP\Vendor\Psr\Http\Message\StreamInterface;
|
||||
class Stream implements \WPMailSMTP\Vendor\Psr\Http\Message\StreamInterface
|
||||
{
|
||||
/**
|
||||
* @see http://php.net/manual/function.fopen.php
|
||||
* @see http://php.net/manual/en/function.gzopen.php
|
||||
* @see https://www.php.net/manual/en/function.fopen.php
|
||||
* @see https://www.php.net/manual/en/function.gzopen.php
|
||||
*/
|
||||
private const READABLE_MODES = '/r|a\\+|ab\\+|w\\+|wb\\+|x\\+|xb\\+|c\\+|cb\\+/';
|
||||
private const WRITABLE_MODES = '/a|w|r\\+|rb\\+|rw|x|c/';
|
||||
|
||||
@@ -60,7 +60,7 @@ trait StreamDecoratorTrait
|
||||
{
|
||||
/** @var callable $callable */
|
||||
$callable = [$this->stream, $method];
|
||||
$result = \call_user_func_array($callable, $args);
|
||||
$result = $callable(...$args);
|
||||
// Always return the wrapped object if the result is a return $this
|
||||
return $result === $this->stream ? $this : $result;
|
||||
}
|
||||
|
||||
@@ -97,7 +97,21 @@ final class StreamWrapper
|
||||
return $resource ?? \false;
|
||||
}
|
||||
/**
|
||||
* @return array<int|string, int>
|
||||
* @return array{
|
||||
* dev: int,
|
||||
* ino: int,
|
||||
* mode: int,
|
||||
* nlink: int,
|
||||
* uid: int,
|
||||
* gid: int,
|
||||
* rdev: int,
|
||||
* size: int,
|
||||
* atime: int,
|
||||
* mtime: int,
|
||||
* ctime: int,
|
||||
* blksize: int,
|
||||
* blocks: int
|
||||
* }
|
||||
*/
|
||||
public function stream_stat() : array
|
||||
{
|
||||
@@ -105,7 +119,21 @@ final class StreamWrapper
|
||||
return ['dev' => 0, 'ino' => 0, 'mode' => $modeMap[$this->mode], 'nlink' => 0, 'uid' => 0, 'gid' => 0, 'rdev' => 0, 'size' => $this->stream->getSize() ?: 0, 'atime' => 0, 'mtime' => 0, 'ctime' => 0, 'blksize' => 0, 'blocks' => 0];
|
||||
}
|
||||
/**
|
||||
* @return array<int|string, int>
|
||||
* @return array{
|
||||
* dev: int,
|
||||
* ino: int,
|
||||
* mode: int,
|
||||
* nlink: int,
|
||||
* uid: int,
|
||||
* gid: int,
|
||||
* rdev: int,
|
||||
* size: int,
|
||||
* atime: int,
|
||||
* mtime: int,
|
||||
* ctime: int,
|
||||
* blksize: int,
|
||||
* blocks: int
|
||||
* }
|
||||
*/
|
||||
public function url_stat(string $path, int $flags) : array
|
||||
{
|
||||
|
||||
@@ -80,7 +80,7 @@ class UploadedFile implements \WPMailSMTP\Vendor\Psr\Http\Message\UploadedFileIn
|
||||
}
|
||||
$this->error = $error;
|
||||
}
|
||||
private function isStringNotEmpty($param) : bool
|
||||
private static function isStringNotEmpty($param) : bool
|
||||
{
|
||||
return \is_string($param) && \false === empty($param);
|
||||
}
|
||||
@@ -120,7 +120,7 @@ class UploadedFile implements \WPMailSMTP\Vendor\Psr\Http\Message\UploadedFileIn
|
||||
public function moveTo($targetPath) : void
|
||||
{
|
||||
$this->validateActive();
|
||||
if (\false === $this->isStringNotEmpty($targetPath)) {
|
||||
if (\false === self::isStringNotEmpty($targetPath)) {
|
||||
throw new \InvalidArgumentException('Invalid path provided for move operation; must be a non-empty string');
|
||||
}
|
||||
if ($this->file) {
|
||||
|
||||
@@ -25,13 +25,13 @@ class Uri implements \WPMailSMTP\Vendor\Psr\Http\Message\UriInterface, \JsonSeri
|
||||
/**
|
||||
* Unreserved characters for use in a regex.
|
||||
*
|
||||
* @see https://tools.ietf.org/html/rfc3986#section-2.3
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-2.3
|
||||
*/
|
||||
private const CHAR_UNRESERVED = 'a-zA-Z0-9_\\-\\.~';
|
||||
/**
|
||||
* Sub-delims for use in a regex.
|
||||
*
|
||||
* @see https://tools.ietf.org/html/rfc3986#section-2.2
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-2.2
|
||||
*/
|
||||
private const CHAR_SUB_DELIMS = '!\\$&\'\\(\\)\\*\\+,;=';
|
||||
private const QUERY_SEPARATORS_REPLACEMENT = ['=' => '%3D', '&' => '%26'];
|
||||
@@ -118,7 +118,7 @@ class Uri implements \WPMailSMTP\Vendor\Psr\Http\Message\UriInterface, \JsonSeri
|
||||
* `file:///` is the more common syntax for the file scheme anyway (Chrome for example redirects to
|
||||
* that format).
|
||||
*
|
||||
* @see https://tools.ietf.org/html/rfc3986#section-5.3
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-5.3
|
||||
*/
|
||||
public static function composeComponents(?string $scheme, ?string $authority, string $path, ?string $query, ?string $fragment) : string
|
||||
{
|
||||
@@ -165,7 +165,7 @@ class Uri implements \WPMailSMTP\Vendor\Psr\Http\Message\UriInterface, \JsonSeri
|
||||
* @see Uri::isNetworkPathReference
|
||||
* @see Uri::isAbsolutePathReference
|
||||
* @see Uri::isRelativePathReference
|
||||
* @see https://tools.ietf.org/html/rfc3986#section-4
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-4
|
||||
*/
|
||||
public static function isAbsolute(\WPMailSMTP\Vendor\Psr\Http\Message\UriInterface $uri) : bool
|
||||
{
|
||||
@@ -176,7 +176,7 @@ class Uri implements \WPMailSMTP\Vendor\Psr\Http\Message\UriInterface, \JsonSeri
|
||||
*
|
||||
* A relative reference that begins with two slash characters is termed an network-path reference.
|
||||
*
|
||||
* @see https://tools.ietf.org/html/rfc3986#section-4.2
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-4.2
|
||||
*/
|
||||
public static function isNetworkPathReference(\WPMailSMTP\Vendor\Psr\Http\Message\UriInterface $uri) : bool
|
||||
{
|
||||
@@ -187,7 +187,7 @@ class Uri implements \WPMailSMTP\Vendor\Psr\Http\Message\UriInterface, \JsonSeri
|
||||
*
|
||||
* A relative reference that begins with a single slash character is termed an absolute-path reference.
|
||||
*
|
||||
* @see https://tools.ietf.org/html/rfc3986#section-4.2
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-4.2
|
||||
*/
|
||||
public static function isAbsolutePathReference(\WPMailSMTP\Vendor\Psr\Http\Message\UriInterface $uri) : bool
|
||||
{
|
||||
@@ -198,7 +198,7 @@ class Uri implements \WPMailSMTP\Vendor\Psr\Http\Message\UriInterface, \JsonSeri
|
||||
*
|
||||
* A relative reference that does not begin with a slash character is termed a relative-path reference.
|
||||
*
|
||||
* @see https://tools.ietf.org/html/rfc3986#section-4.2
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-4.2
|
||||
*/
|
||||
public static function isRelativePathReference(\WPMailSMTP\Vendor\Psr\Http\Message\UriInterface $uri) : bool
|
||||
{
|
||||
@@ -214,7 +214,7 @@ class Uri implements \WPMailSMTP\Vendor\Psr\Http\Message\UriInterface, \JsonSeri
|
||||
* @param UriInterface $uri The URI to check
|
||||
* @param UriInterface|null $base An optional base URI to compare against
|
||||
*
|
||||
* @see https://tools.ietf.org/html/rfc3986#section-4.4
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-4.4
|
||||
*/
|
||||
public static function isSameDocumentReference(\WPMailSMTP\Vendor\Psr\Http\Message\UriInterface $uri, \WPMailSMTP\Vendor\Psr\Http\Message\UriInterface $base = null) : bool
|
||||
{
|
||||
@@ -262,8 +262,8 @@ class Uri implements \WPMailSMTP\Vendor\Psr\Http\Message\UriInterface, \JsonSeri
|
||||
*
|
||||
* It has the same behavior as withQueryValue() but for an associative array of key => value.
|
||||
*
|
||||
* @param UriInterface $uri URI to use as a base.
|
||||
* @param array<string, string|null> $keyValueArray Associative array of key and values
|
||||
* @param UriInterface $uri URI to use as a base.
|
||||
* @param (string|null)[] $keyValueArray Associative array of key and values
|
||||
*/
|
||||
public static function withQueryValues(\WPMailSMTP\Vendor\Psr\Http\Message\UriInterface $uri, array $keyValueArray) : \WPMailSMTP\Vendor\Psr\Http\Message\UriInterface
|
||||
{
|
||||
@@ -276,7 +276,7 @@ class Uri implements \WPMailSMTP\Vendor\Psr\Http\Message\UriInterface, \JsonSeri
|
||||
/**
|
||||
* Creates a URI from a hash of `parse_url` components.
|
||||
*
|
||||
* @see http://php.net/manual/en/function.parse-url.php
|
||||
* @see https://www.php.net/manual/en/function.parse-url.php
|
||||
*
|
||||
* @throws MalformedUriException If the components do not form a valid URI.
|
||||
*/
|
||||
@@ -489,7 +489,7 @@ class Uri implements \WPMailSMTP\Vendor\Psr\Http\Message\UriInterface, \JsonSeri
|
||||
return $port;
|
||||
}
|
||||
/**
|
||||
* @param string[] $keys
|
||||
* @param (string|int)[] $keys
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
@@ -499,7 +499,9 @@ class Uri implements \WPMailSMTP\Vendor\Psr\Http\Message\UriInterface, \JsonSeri
|
||||
if ($current === '') {
|
||||
return [];
|
||||
}
|
||||
$decodedKeys = \array_map('rawurldecode', $keys);
|
||||
$decodedKeys = \array_map(function ($k) : string {
|
||||
return \rawurldecode((string) $k);
|
||||
}, $keys);
|
||||
return \array_filter(\explode('&', $current), function ($part) use($decodedKeys) {
|
||||
return !\in_array(\rawurldecode(\explode('=', $part)[0]), $decodedKeys, \true);
|
||||
});
|
||||
|
||||
@@ -9,7 +9,7 @@ use WPMailSMTP\Vendor\Psr\Http\Message\UriInterface;
|
||||
*
|
||||
* @author Tobias Schultze
|
||||
*
|
||||
* @see https://tools.ietf.org/html/rfc3986#section-6
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-6
|
||||
*/
|
||||
final class UriNormalizer
|
||||
{
|
||||
@@ -102,7 +102,7 @@ final class UriNormalizer
|
||||
* @param UriInterface $uri The URI to normalize
|
||||
* @param int $flags A bitmask of normalizations to apply, see constants
|
||||
*
|
||||
* @see https://tools.ietf.org/html/rfc3986#section-6.2
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-6.2
|
||||
*/
|
||||
public static function normalize(\WPMailSMTP\Vendor\Psr\Http\Message\UriInterface $uri, int $flags = self::PRESERVING_NORMALIZATIONS) : \WPMailSMTP\Vendor\Psr\Http\Message\UriInterface
|
||||
{
|
||||
@@ -146,7 +146,7 @@ final class UriNormalizer
|
||||
* @param UriInterface $uri2 An URI to compare
|
||||
* @param int $normalizations A bitmask of normalizations to apply, see constants
|
||||
*
|
||||
* @see https://tools.ietf.org/html/rfc3986#section-6.1
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-6.1
|
||||
*/
|
||||
public static function isEquivalent(\WPMailSMTP\Vendor\Psr\Http\Message\UriInterface $uri1, \WPMailSMTP\Vendor\Psr\Http\Message\UriInterface $uri2, int $normalizations = self::PRESERVING_NORMALIZATIONS) : bool
|
||||
{
|
||||
@@ -155,7 +155,7 @@ final class UriNormalizer
|
||||
private static function capitalizePercentEncoding(\WPMailSMTP\Vendor\Psr\Http\Message\UriInterface $uri) : \WPMailSMTP\Vendor\Psr\Http\Message\UriInterface
|
||||
{
|
||||
$regex = '/(?:%[A-Fa-f0-9]{2})++/';
|
||||
$callback = function (array $match) {
|
||||
$callback = function (array $match) : string {
|
||||
return \strtoupper($match[0]);
|
||||
};
|
||||
return $uri->withPath(\preg_replace_callback($regex, $callback, $uri->getPath()))->withQuery(\preg_replace_callback($regex, $callback, $uri->getQuery()));
|
||||
@@ -163,7 +163,7 @@ final class UriNormalizer
|
||||
private static function decodeUnreservedCharacters(\WPMailSMTP\Vendor\Psr\Http\Message\UriInterface $uri) : \WPMailSMTP\Vendor\Psr\Http\Message\UriInterface
|
||||
{
|
||||
$regex = '/%(?:2D|2E|5F|7E|3[0-9]|[46][1-9A-F]|[57][0-9A])/i';
|
||||
$callback = function (array $match) {
|
||||
$callback = function (array $match) : string {
|
||||
return \rawurldecode($match[0]);
|
||||
};
|
||||
return $uri->withPath(\preg_replace_callback($regex, $callback, $uri->getPath()))->withQuery(\preg_replace_callback($regex, $callback, $uri->getQuery()));
|
||||
|
||||
@@ -9,14 +9,14 @@ use WPMailSMTP\Vendor\Psr\Http\Message\UriInterface;
|
||||
*
|
||||
* @author Tobias Schultze
|
||||
*
|
||||
* @see https://tools.ietf.org/html/rfc3986#section-5
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-5
|
||||
*/
|
||||
final class UriResolver
|
||||
{
|
||||
/**
|
||||
* Removes dot segments from a path and returns the new path.
|
||||
*
|
||||
* @see http://tools.ietf.org/html/rfc3986#section-5.2.4
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-5.2.4
|
||||
*/
|
||||
public static function removeDotSegments(string $path) : string
|
||||
{
|
||||
@@ -46,7 +46,7 @@ final class UriResolver
|
||||
/**
|
||||
* Converts the relative URI into a new URI that is resolved against the base URI.
|
||||
*
|
||||
* @see http://tools.ietf.org/html/rfc3986#section-5.2
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-5.2
|
||||
*/
|
||||
public static function resolve(\WPMailSMTP\Vendor\Psr\Http\Message\UriInterface $base, \WPMailSMTP\Vendor\Psr\Http\Message\UriInterface $rel) : \WPMailSMTP\Vendor\Psr\Http\Message\UriInterface
|
||||
{
|
||||
|
||||
@@ -12,16 +12,16 @@ final class Utils
|
||||
/**
|
||||
* Remove the items given by the keys, case insensitively from the data.
|
||||
*
|
||||
* @param string[] $keys
|
||||
* @param (string|int)[] $keys
|
||||
*/
|
||||
public static function caselessRemove(array $keys, array $data) : array
|
||||
{
|
||||
$result = [];
|
||||
foreach ($keys as &$key) {
|
||||
$key = \strtolower($key);
|
||||
$key = \strtolower((string) $key);
|
||||
}
|
||||
foreach ($data as $k => $v) {
|
||||
if (!\is_string($k) || !\in_array(\strtolower($k), $keys)) {
|
||||
if (!\in_array(\strtolower((string) $k), $keys)) {
|
||||
$result[$k] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 - 2018 Paragon Initiative Enterprises
|
||||
Copyright (c) 2016 - 2022 Paragon Initiative Enterprises
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace WPMailSMTP\Vendor\ParagonIE\ConstantTime;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use RangeException;
|
||||
use TypeError;
|
||||
/**
|
||||
* Copyright (c) 2016 - 2017 Paragon Initiative Enterprises.
|
||||
* Copyright (c) 2016 - 2022 Paragon Initiative Enterprises.
|
||||
* Copyright (c) 2014 Steve "Sc00bz" Thomas (steve at tobtu dot com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
@@ -35,13 +39,13 @@ abstract class Base32 implements \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Encod
|
||||
/**
|
||||
* Decode a Base32-encoded string into raw binary
|
||||
*
|
||||
* @param string $encoded_string
|
||||
* @param string $encodedString
|
||||
* @param bool $strictPadding
|
||||
* @return string
|
||||
*/
|
||||
public static function decode($encoded_string, $strictPadding = \false)
|
||||
public static function decode(string $encodedString, bool $strictPadding = \false) : string
|
||||
{
|
||||
return static::doDecode($encoded_string, \false, $strictPadding);
|
||||
return static::doDecode($encodedString, \false, $strictPadding);
|
||||
}
|
||||
/**
|
||||
* Decode an uppercase Base32-encoded string into raw binary
|
||||
@@ -50,28 +54,29 @@ abstract class Base32 implements \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Encod
|
||||
* @param bool $strictPadding
|
||||
* @return string
|
||||
*/
|
||||
public static function decodeUpper($src, $strictPadding = \false)
|
||||
public static function decodeUpper(string $src, bool $strictPadding = \false) : string
|
||||
{
|
||||
return static::doDecode($src, \true, $strictPadding);
|
||||
}
|
||||
/**
|
||||
* Encode into Base32 (RFC 4648)
|
||||
*
|
||||
* @param string $bin_string
|
||||
* @param string $binString
|
||||
* @return string
|
||||
* @throws TypeError
|
||||
*/
|
||||
public static function encode($bin_string)
|
||||
public static function encode(string $binString) : string
|
||||
{
|
||||
return static::doEncode($bin_string, \false);
|
||||
return static::doEncode($binString, \false, \true);
|
||||
}
|
||||
/**
|
||||
* Encode into Base32 (RFC 4648)
|
||||
*
|
||||
* @param string $src
|
||||
* @return string
|
||||
* @throws \TypeError
|
||||
* @throws TypeError
|
||||
*/
|
||||
public static function encodeUnpadded($src)
|
||||
public static function encodeUnpadded(string $src) : string
|
||||
{
|
||||
return static::doEncode($src, \false, \false);
|
||||
}
|
||||
@@ -80,19 +85,20 @@ abstract class Base32 implements \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Encod
|
||||
*
|
||||
* @param string $src
|
||||
* @return string
|
||||
* @throws TypeError
|
||||
*/
|
||||
public static function encodeUpper($src)
|
||||
public static function encodeUpper(string $src) : string
|
||||
{
|
||||
return static::doEncode($src, \true);
|
||||
return static::doEncode($src, \true, \true);
|
||||
}
|
||||
/**
|
||||
* Encode into uppercase Base32 (RFC 4648)
|
||||
*
|
||||
* @param string $src
|
||||
* @return string
|
||||
* @throws \TypeError
|
||||
* @throws TypeError
|
||||
*/
|
||||
public static function encodeUpperUnpadded($src)
|
||||
public static function encodeUpperUnpadded(string $src) : string
|
||||
{
|
||||
return static::doEncode($src, \true, \false);
|
||||
}
|
||||
@@ -103,7 +109,7 @@ abstract class Base32 implements \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Encod
|
||||
* @param int $src
|
||||
* @return int
|
||||
*/
|
||||
protected static function decode5Bits($src)
|
||||
protected static function decode5Bits(int $src) : int
|
||||
{
|
||||
$ret = -1;
|
||||
// if ($src > 96 && $src < 123) $ret += $src - 97 + 1; // -64
|
||||
@@ -121,7 +127,7 @@ abstract class Base32 implements \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Encod
|
||||
* @param int $src
|
||||
* @return int
|
||||
*/
|
||||
protected static function decode5BitsUpper($src)
|
||||
protected static function decode5BitsUpper(int $src) : int
|
||||
{
|
||||
$ret = -1;
|
||||
// if ($src > 64 && $src < 91) $ret += $src - 65 + 1; // -64
|
||||
@@ -137,7 +143,7 @@ abstract class Base32 implements \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Encod
|
||||
* @param int $src
|
||||
* @return string
|
||||
*/
|
||||
protected static function encode5Bits($src)
|
||||
protected static function encode5Bits(int $src) : string
|
||||
{
|
||||
$diff = 0x61;
|
||||
// if ($src > 25) $ret -= 72;
|
||||
@@ -153,13 +159,33 @@ abstract class Base32 implements \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Encod
|
||||
* @param int $src
|
||||
* @return string
|
||||
*/
|
||||
protected static function encode5BitsUpper($src)
|
||||
protected static function encode5BitsUpper(int $src) : string
|
||||
{
|
||||
$diff = 0x41;
|
||||
// if ($src > 25) $ret -= 40;
|
||||
$diff -= 25 - $src >> 8 & 41;
|
||||
return \pack('C', $src + $diff);
|
||||
}
|
||||
/**
|
||||
* @param string $encodedString
|
||||
* @param bool $upper
|
||||
* @return string
|
||||
*/
|
||||
public static function decodeNoPadding(string $encodedString, bool $upper = \false) : string
|
||||
{
|
||||
$srcLen = \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Binary::safeStrlen($encodedString);
|
||||
if ($srcLen === 0) {
|
||||
return '';
|
||||
}
|
||||
if (($srcLen & 7) === 0) {
|
||||
for ($j = 0; $j < 7 && $j < $srcLen; ++$j) {
|
||||
if ($encodedString[$srcLen - $j - 1] === '=') {
|
||||
throw new \InvalidArgumentException("decodeNoPadding() doesn't tolerate padding");
|
||||
}
|
||||
}
|
||||
}
|
||||
return static::doDecode($encodedString, $upper, \true);
|
||||
}
|
||||
/**
|
||||
* Base32 decoding
|
||||
*
|
||||
@@ -167,8 +193,11 @@ abstract class Base32 implements \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Encod
|
||||
* @param bool $upper
|
||||
* @param bool $strictPadding
|
||||
* @return string
|
||||
*
|
||||
* @throws TypeError
|
||||
* @psalm-suppress RedundantCondition
|
||||
*/
|
||||
protected static function doDecode($src, $upper = \false, $strictPadding = \true)
|
||||
protected static function doDecode(string $src, bool $upper = \false, bool $strictPadding = \false) : string
|
||||
{
|
||||
// We do this to reduce code duplication:
|
||||
$method = $upper ? 'decode5BitsUpper' : 'decode5Bits';
|
||||
@@ -198,80 +227,129 @@ abstract class Base32 implements \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Encod
|
||||
$dest = '';
|
||||
// Main loop (no padding):
|
||||
for ($i = 0; $i + 8 <= $srcLen; $i += 8) {
|
||||
/** @var array<int, int> $chunk */
|
||||
$chunk = \unpack('C*', \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Binary::safeSubstr($src, $i, 8));
|
||||
/** @var int $c0 */
|
||||
$c0 = static::$method($chunk[1]);
|
||||
/** @var int $c1 */
|
||||
$c1 = static::$method($chunk[2]);
|
||||
/** @var int $c2 */
|
||||
$c2 = static::$method($chunk[3]);
|
||||
/** @var int $c3 */
|
||||
$c3 = static::$method($chunk[4]);
|
||||
/** @var int $c4 */
|
||||
$c4 = static::$method($chunk[5]);
|
||||
/** @var int $c5 */
|
||||
$c5 = static::$method($chunk[6]);
|
||||
/** @var int $c6 */
|
||||
$c6 = static::$method($chunk[7]);
|
||||
/** @var int $c7 */
|
||||
$c7 = static::$method($chunk[8]);
|
||||
$dest .= \pack('CCCCC', ($c0 << 3 | $c1 >> 2) & 0xff, ($c1 << 6 | $c2 << 1 | $c3 >> 4) & 0xff, ($c3 << 4 | $c4 >> 1) & 0xff, ($c4 << 7 | $c5 << 2 | $c6 >> 3) & 0xff, ($c6 << 5 | $c7) & 0xff);
|
||||
$err |= ($c0 | $c1 | $c2 | $c3 | $c4 | $c5 | $c6 | $c7) >> 8;
|
||||
}
|
||||
// The last chunk, which may have padding:
|
||||
if ($i < $srcLen) {
|
||||
/** @var array<int, int> $chunk */
|
||||
$chunk = \unpack('C*', \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Binary::safeSubstr($src, $i, $srcLen - $i));
|
||||
/** @var int $c0 */
|
||||
$c0 = static::$method($chunk[1]);
|
||||
if ($i + 6 < $srcLen) {
|
||||
/** @var int $c1 */
|
||||
$c1 = static::$method($chunk[2]);
|
||||
/** @var int $c2 */
|
||||
$c2 = static::$method($chunk[3]);
|
||||
/** @var int $c3 */
|
||||
$c3 = static::$method($chunk[4]);
|
||||
/** @var int $c4 */
|
||||
$c4 = static::$method($chunk[5]);
|
||||
/** @var int $c5 */
|
||||
$c5 = static::$method($chunk[6]);
|
||||
/** @var int $c6 */
|
||||
$c6 = static::$method($chunk[7]);
|
||||
$dest .= \pack('CCCC', ($c0 << 3 | $c1 >> 2) & 0xff, ($c1 << 6 | $c2 << 1 | $c3 >> 4) & 0xff, ($c3 << 4 | $c4 >> 1) & 0xff, ($c4 << 7 | $c5 << 2 | $c6 >> 3) & 0xff);
|
||||
$err |= ($c0 | $c1 | $c2 | $c3 | $c4 | $c5 | $c6) >> 8;
|
||||
if ($strictPadding) {
|
||||
$err |= $c6 << 5 & 0xff;
|
||||
}
|
||||
} elseif ($i + 5 < $srcLen) {
|
||||
/** @var int $c1 */
|
||||
$c1 = static::$method($chunk[2]);
|
||||
/** @var int $c2 */
|
||||
$c2 = static::$method($chunk[3]);
|
||||
/** @var int $c3 */
|
||||
$c3 = static::$method($chunk[4]);
|
||||
/** @var int $c4 */
|
||||
$c4 = static::$method($chunk[5]);
|
||||
/** @var int $c5 */
|
||||
$c5 = static::$method($chunk[6]);
|
||||
$dest .= \pack('CCCC', ($c0 << 3 | $c1 >> 2) & 0xff, ($c1 << 6 | $c2 << 1 | $c3 >> 4) & 0xff, ($c3 << 4 | $c4 >> 1) & 0xff, ($c4 << 7 | $c5 << 2) & 0xff);
|
||||
$err |= ($c0 | $c1 | $c2 | $c3 | $c4 | $c5) >> 8;
|
||||
} elseif ($i + 4 < $srcLen) {
|
||||
/** @var int $c1 */
|
||||
$c1 = static::$method($chunk[2]);
|
||||
/** @var int $c2 */
|
||||
$c2 = static::$method($chunk[3]);
|
||||
/** @var int $c3 */
|
||||
$c3 = static::$method($chunk[4]);
|
||||
/** @var int $c4 */
|
||||
$c4 = static::$method($chunk[5]);
|
||||
$dest .= \pack('CCC', ($c0 << 3 | $c1 >> 2) & 0xff, ($c1 << 6 | $c2 << 1 | $c3 >> 4) & 0xff, ($c3 << 4 | $c4 >> 1) & 0xff);
|
||||
$err |= ($c0 | $c1 | $c2 | $c3 | $c4) >> 8;
|
||||
if ($strictPadding) {
|
||||
$err |= $c4 << 7 & 0xff;
|
||||
}
|
||||
} elseif ($i + 3 < $srcLen) {
|
||||
/** @var int $c1 */
|
||||
$c1 = static::$method($chunk[2]);
|
||||
/** @var int $c2 */
|
||||
$c2 = static::$method($chunk[3]);
|
||||
/** @var int $c3 */
|
||||
$c3 = static::$method($chunk[4]);
|
||||
$dest .= \pack('CC', ($c0 << 3 | $c1 >> 2) & 0xff, ($c1 << 6 | $c2 << 1 | $c3 >> 4) & 0xff);
|
||||
$err |= ($c0 | $c1 | $c2 | $c3) >> 8;
|
||||
if ($strictPadding) {
|
||||
$err |= $c3 << 4 & 0xff;
|
||||
}
|
||||
} elseif ($i + 2 < $srcLen) {
|
||||
/** @var int $c1 */
|
||||
$c1 = static::$method($chunk[2]);
|
||||
/** @var int $c2 */
|
||||
$c2 = static::$method($chunk[3]);
|
||||
$dest .= \pack('CC', ($c0 << 3 | $c1 >> 2) & 0xff, ($c1 << 6 | $c2 << 1) & 0xff);
|
||||
$err |= ($c0 | $c1 | $c2) >> 8;
|
||||
if ($strictPadding) {
|
||||
$err |= $c2 << 6 & 0xff;
|
||||
}
|
||||
} elseif ($i + 1 < $srcLen) {
|
||||
/** @var int $c1 */
|
||||
$c1 = static::$method($chunk[2]);
|
||||
$dest .= \pack('C', ($c0 << 3 | $c1 >> 2) & 0xff);
|
||||
$err |= ($c0 | $c1) >> 8;
|
||||
if ($strictPadding) {
|
||||
$err |= $c1 << 6 & 0xff;
|
||||
}
|
||||
} else {
|
||||
$dest .= \pack('C', $c0 << 3 & 0xff);
|
||||
$err |= $c0 >> 8;
|
||||
}
|
||||
}
|
||||
if ($err !== 0) {
|
||||
$check = $err === 0;
|
||||
if (!$check) {
|
||||
throw new \RangeException('Base32::doDecode() only expects characters in the correct base32 alphabet');
|
||||
}
|
||||
return $dest;
|
||||
}
|
||||
/**
|
||||
* Base32 Decoding
|
||||
* Base32 Encoding
|
||||
*
|
||||
* @param string $src
|
||||
* @param bool $upper
|
||||
* @param bool $pad
|
||||
* @return string
|
||||
* @throws TypeError
|
||||
*/
|
||||
protected static function doEncode($src, $upper = \false, $pad = \true)
|
||||
protected static function doEncode(string $src, bool $upper = \false, $pad = \true) : string
|
||||
{
|
||||
// We do this to reduce code duplication:
|
||||
$method = $upper ? 'encode5BitsUpper' : 'encode5Bits';
|
||||
@@ -279,6 +357,7 @@ abstract class Base32 implements \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Encod
|
||||
$srcLen = \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Binary::safeStrlen($src);
|
||||
// Main loop (no padding):
|
||||
for ($i = 0; $i + 5 <= $srcLen; $i += 5) {
|
||||
/** @var array<int, int> $chunk */
|
||||
$chunk = \unpack('C*', \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Binary::safeSubstr($src, $i, 5));
|
||||
$b0 = $chunk[1];
|
||||
$b1 = $chunk[2];
|
||||
@@ -289,6 +368,7 @@ abstract class Base32 implements \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Encod
|
||||
}
|
||||
// The last chunk, which may have padding:
|
||||
if ($i < $srcLen) {
|
||||
/** @var array<int, int> $chunk */
|
||||
$chunk = \unpack('C*', \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Binary::safeSubstr($src, $i, $srcLen - $i));
|
||||
$b0 = $chunk[1];
|
||||
if ($i + 3 < $srcLen) {
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace WPMailSMTP\Vendor\ParagonIE\ConstantTime;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2016 - 2017 Paragon Initiative Enterprises.
|
||||
* Copyright (c) 2016 - 2022 Paragon Initiative Enterprises.
|
||||
* Copyright (c) 2014 Steve "Sc00bz" Thomas (steve at tobtu dot com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
@@ -39,7 +40,7 @@ abstract class Base32Hex extends \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Base3
|
||||
* @param int $src
|
||||
* @return int
|
||||
*/
|
||||
protected static function decode5Bits($src)
|
||||
protected static function decode5Bits(int $src) : int
|
||||
{
|
||||
$ret = -1;
|
||||
// if ($src > 0x30 && $src < 0x3a) ret += $src - 0x2e + 1; // -47
|
||||
@@ -55,7 +56,7 @@ abstract class Base32Hex extends \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Base3
|
||||
* @param int $src
|
||||
* @return int
|
||||
*/
|
||||
protected static function decode5BitsUpper($src)
|
||||
protected static function decode5BitsUpper(int $src) : int
|
||||
{
|
||||
$ret = -1;
|
||||
// if ($src > 0x30 && $src < 0x3a) ret += $src - 0x2e + 1; // -47
|
||||
@@ -71,7 +72,7 @@ abstract class Base32Hex extends \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Base3
|
||||
* @param int $src
|
||||
* @return string
|
||||
*/
|
||||
protected static function encode5Bits($src)
|
||||
protected static function encode5Bits(int $src) : string
|
||||
{
|
||||
$src += 0x30;
|
||||
// if ($src > 0x39) $src += 0x61 - 0x3a; // 39
|
||||
@@ -87,7 +88,7 @@ abstract class Base32Hex extends \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Base3
|
||||
* @param int $src
|
||||
* @return string
|
||||
*/
|
||||
protected static function encode5BitsUpper($src)
|
||||
protected static function encode5BitsUpper(int $src) : string
|
||||
{
|
||||
$src += 0x30;
|
||||
// if ($src > 0x39) $src += 0x41 - 0x3a; // 7
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace WPMailSMTP\Vendor\ParagonIE\ConstantTime;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use RangeException;
|
||||
use TypeError;
|
||||
/**
|
||||
* Copyright (c) 2016 - 2017 Paragon Initiative Enterprises.
|
||||
* Copyright (c) 2016 - 2022 Paragon Initiative Enterprises.
|
||||
* Copyright (c) 2014 Steve "Sc00bz" Thomas (steve at tobtu dot com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
@@ -37,12 +41,14 @@ abstract class Base64 implements \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Encod
|
||||
*
|
||||
* Base64 character set "[A-Z][a-z][0-9]+/"
|
||||
*
|
||||
* @param string $bin_string
|
||||
* @param string $binString
|
||||
* @return string
|
||||
*
|
||||
* @throws TypeError
|
||||
*/
|
||||
public static function encode($bin_string)
|
||||
public static function encode(string $binString) : string
|
||||
{
|
||||
return static::doEncode($bin_string, \true);
|
||||
return static::doEncode($binString, \true);
|
||||
}
|
||||
/**
|
||||
* Encode into Base64, no = padding
|
||||
@@ -51,8 +57,10 @@ abstract class Base64 implements \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Encod
|
||||
*
|
||||
* @param string $src
|
||||
* @return string
|
||||
*
|
||||
* @throws TypeError
|
||||
*/
|
||||
public static function encodeUnpadded($src)
|
||||
public static function encodeUnpadded(string $src) : string
|
||||
{
|
||||
return static::doEncode($src, \false);
|
||||
}
|
||||
@@ -60,13 +68,16 @@ abstract class Base64 implements \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Encod
|
||||
* @param string $src
|
||||
* @param bool $pad Include = padding?
|
||||
* @return string
|
||||
*
|
||||
* @throws TypeError
|
||||
*/
|
||||
protected static function doEncode($src, $pad = \true)
|
||||
protected static function doEncode(string $src, bool $pad = \true) : string
|
||||
{
|
||||
$dest = '';
|
||||
$srcLen = \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Binary::safeStrlen($src);
|
||||
// Main loop (no padding):
|
||||
for ($i = 0; $i + 3 <= $srcLen; $i += 3) {
|
||||
/** @var array<int, int> $chunk */
|
||||
$chunk = \unpack('C*', \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Binary::safeSubstr($src, $i, 3));
|
||||
$b0 = $chunk[1];
|
||||
$b1 = $chunk[2];
|
||||
@@ -75,6 +86,7 @@ abstract class Base64 implements \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Encod
|
||||
}
|
||||
// The last chunk, which may have padding:
|
||||
if ($i < $srcLen) {
|
||||
/** @var array<int, int> $chunk */
|
||||
$chunk = \unpack('C*', \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Binary::safeSubstr($src, $i, $srcLen - $i));
|
||||
$b0 = $chunk[1];
|
||||
if ($i + 1 < $srcLen) {
|
||||
@@ -97,23 +109,26 @@ abstract class Base64 implements \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Encod
|
||||
*
|
||||
* Base64 character set "./[A-Z][a-z][0-9]"
|
||||
*
|
||||
* @param string $encoded_string
|
||||
* @param string $encodedString
|
||||
* @param bool $strictPadding
|
||||
* @return string
|
||||
* @throws \RangeException
|
||||
*
|
||||
* @throws RangeException
|
||||
* @throws TypeError
|
||||
* @psalm-suppress RedundantCondition
|
||||
*/
|
||||
public static function decode($encoded_string, $strictPadding = \false)
|
||||
public static function decode(string $encodedString, bool $strictPadding = \false) : string
|
||||
{
|
||||
// Remove padding
|
||||
$srcLen = \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Binary::safeStrlen($encoded_string);
|
||||
$srcLen = \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Binary::safeStrlen($encodedString);
|
||||
if ($srcLen === 0) {
|
||||
return '';
|
||||
}
|
||||
if ($strictPadding) {
|
||||
if (($srcLen & 3) === 0) {
|
||||
if ($encoded_string[$srcLen - 1] === '=') {
|
||||
if ($encodedString[$srcLen - 1] === '=') {
|
||||
$srcLen--;
|
||||
if ($encoded_string[$srcLen - 1] === '=') {
|
||||
if ($encodedString[$srcLen - 1] === '=') {
|
||||
$srcLen--;
|
||||
}
|
||||
}
|
||||
@@ -121,15 +136,19 @@ abstract class Base64 implements \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Encod
|
||||
if (($srcLen & 3) === 1) {
|
||||
throw new \RangeException('Incorrect padding');
|
||||
}
|
||||
if ($encodedString[$srcLen - 1] === '=') {
|
||||
throw new \RangeException('Incorrect padding');
|
||||
}
|
||||
} else {
|
||||
$encoded_string = \rtrim($encoded_string, '=');
|
||||
$srcLen = \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Binary::safeStrlen($encoded_string);
|
||||
$encodedString = \rtrim($encodedString, '=');
|
||||
$srcLen = \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Binary::safeStrlen($encodedString);
|
||||
}
|
||||
$err = 0;
|
||||
$dest = '';
|
||||
// Main loop (no padding):
|
||||
for ($i = 0; $i + 4 <= $srcLen; $i += 4) {
|
||||
$chunk = \unpack('C*', \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Binary::safeSubstr($encoded_string, $i, 4));
|
||||
/** @var array<int, int> $chunk */
|
||||
$chunk = \unpack('C*', \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Binary::safeSubstr($encodedString, $i, 4));
|
||||
$c0 = static::decode6Bits($chunk[1]);
|
||||
$c1 = static::decode6Bits($chunk[2]);
|
||||
$c2 = static::decode6Bits($chunk[3]);
|
||||
@@ -139,26 +158,56 @@ abstract class Base64 implements \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Encod
|
||||
}
|
||||
// The last chunk, which may have padding:
|
||||
if ($i < $srcLen) {
|
||||
$chunk = \unpack('C*', \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Binary::safeSubstr($encoded_string, $i, $srcLen - $i));
|
||||
/** @var array<int, int> $chunk */
|
||||
$chunk = \unpack('C*', \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Binary::safeSubstr($encodedString, $i, $srcLen - $i));
|
||||
$c0 = static::decode6Bits($chunk[1]);
|
||||
if ($i + 2 < $srcLen) {
|
||||
$c1 = static::decode6Bits($chunk[2]);
|
||||
$c2 = static::decode6Bits($chunk[3]);
|
||||
$dest .= \pack('CC', ($c0 << 2 | $c1 >> 4) & 0xff, ($c1 << 4 | $c2 >> 2) & 0xff);
|
||||
$err |= ($c0 | $c1 | $c2) >> 8;
|
||||
if ($strictPadding) {
|
||||
$err |= $c2 << 6 & 0xff;
|
||||
}
|
||||
} elseif ($i + 1 < $srcLen) {
|
||||
$c1 = static::decode6Bits($chunk[2]);
|
||||
$dest .= \pack('C', ($c0 << 2 | $c1 >> 4) & 0xff);
|
||||
$err |= ($c0 | $c1) >> 8;
|
||||
} elseif ($i < $srcLen && $strictPadding) {
|
||||
if ($strictPadding) {
|
||||
$err |= $c1 << 4 & 0xff;
|
||||
}
|
||||
} elseif ($strictPadding) {
|
||||
$err |= 1;
|
||||
}
|
||||
}
|
||||
if ($err !== 0) {
|
||||
$check = $err === 0;
|
||||
if (!$check) {
|
||||
throw new \RangeException('Base64::decode() only expects characters in the correct base64 alphabet');
|
||||
}
|
||||
return $dest;
|
||||
}
|
||||
/**
|
||||
* @param string $encodedString
|
||||
* @return string
|
||||
*/
|
||||
public static function decodeNoPadding(string $encodedString) : string
|
||||
{
|
||||
$srcLen = \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Binary::safeStrlen($encodedString);
|
||||
if ($srcLen === 0) {
|
||||
return '';
|
||||
}
|
||||
if (($srcLen & 3) === 0) {
|
||||
if ($encodedString[$srcLen - 1] === '=') {
|
||||
throw new \InvalidArgumentException("decodeNoPadding() doesn't tolerate padding");
|
||||
}
|
||||
if (($srcLen & 3) > 1) {
|
||||
if ($encodedString[$srcLen - 2] === '=') {
|
||||
throw new \InvalidArgumentException("decodeNoPadding() doesn't tolerate padding");
|
||||
}
|
||||
}
|
||||
}
|
||||
return static::decode($encodedString, \true);
|
||||
}
|
||||
/**
|
||||
* Uses bitwise operators instead of table-lookups to turn 6-bit integers
|
||||
* into 8-bit integers.
|
||||
@@ -170,7 +219,7 @@ abstract class Base64 implements \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Encod
|
||||
* @param int $src
|
||||
* @return int
|
||||
*/
|
||||
protected static function decode6Bits($src)
|
||||
protected static function decode6Bits(int $src) : int
|
||||
{
|
||||
$ret = -1;
|
||||
// if ($src > 0x40 && $src < 0x5b) $ret += $src - 0x41 + 1; // -64
|
||||
@@ -192,7 +241,7 @@ abstract class Base64 implements \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Encod
|
||||
* @param int $src
|
||||
* @return string
|
||||
*/
|
||||
protected static function encode6Bits($src)
|
||||
protected static function encode6Bits(int $src) : string
|
||||
{
|
||||
$diff = 0x41;
|
||||
// if ($src > 25) $diff += 0x61 - 0x41 - 26; // 6
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace WPMailSMTP\Vendor\ParagonIE\ConstantTime;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2016 - 2017 Paragon Initiative Enterprises.
|
||||
* Copyright (c) 2016 - 2022 Paragon Initiative Enterprises.
|
||||
* Copyright (c) 2014 Steve "Sc00bz" Thomas (steve at tobtu dot com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
@@ -43,7 +44,7 @@ abstract class Base64DotSlash extends \WPMailSMTP\Vendor\ParagonIE\ConstantTime\
|
||||
* @param int $src
|
||||
* @return int
|
||||
*/
|
||||
protected static function decode6Bits($src)
|
||||
protected static function decode6Bits(int $src) : int
|
||||
{
|
||||
$ret = -1;
|
||||
// if ($src > 0x2d && $src < 0x30) ret += $src - 0x2e + 1; // -45
|
||||
@@ -63,7 +64,7 @@ abstract class Base64DotSlash extends \WPMailSMTP\Vendor\ParagonIE\ConstantTime\
|
||||
* @param int $src
|
||||
* @return string
|
||||
*/
|
||||
protected static function encode6Bits($src)
|
||||
protected static function encode6Bits(int $src) : string
|
||||
{
|
||||
$src += 0x2e;
|
||||
// if ($src > 0x2f) $src += 0x41 - 0x30; // 17
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace WPMailSMTP\Vendor\ParagonIE\ConstantTime;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2016 - 2017 Paragon Initiative Enterprises.
|
||||
* Copyright (c) 2016 - 2022 Paragon Initiative Enterprises.
|
||||
* Copyright (c) 2014 Steve "Sc00bz" Thomas (steve at tobtu dot com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
@@ -43,7 +44,7 @@ abstract class Base64DotSlashOrdered extends \WPMailSMTP\Vendor\ParagonIE\Consta
|
||||
* @param int $src
|
||||
* @return int
|
||||
*/
|
||||
protected static function decode6Bits($src)
|
||||
protected static function decode6Bits(int $src) : int
|
||||
{
|
||||
$ret = -1;
|
||||
// if ($src > 0x2d && $src < 0x3a) ret += $src - 0x2e + 1; // -45
|
||||
@@ -61,7 +62,7 @@ abstract class Base64DotSlashOrdered extends \WPMailSMTP\Vendor\ParagonIE\Consta
|
||||
* @param int $src
|
||||
* @return string
|
||||
*/
|
||||
protected static function encode6Bits($src)
|
||||
protected static function encode6Bits(int $src) : string
|
||||
{
|
||||
$src += 0x2e;
|
||||
// if ($src > 0x39) $src += 0x41 - 0x3a; // 7
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace WPMailSMTP\Vendor\ParagonIE\ConstantTime;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2016 - 2017 Paragon Initiative Enterprises.
|
||||
* Copyright (c) 2016 - 2022 Paragon Initiative Enterprises.
|
||||
* Copyright (c) 2014 Steve "Sc00bz" Thomas (steve at tobtu dot com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
@@ -25,8 +26,8 @@ namespace WPMailSMTP\Vendor\ParagonIE\ConstantTime;
|
||||
* SOFTWARE.
|
||||
*/
|
||||
/**
|
||||
* Class Base64DotSlash
|
||||
* ./[A-Z][a-z][0-9]
|
||||
* Class Base64UrlSafe
|
||||
* [A-Z][a-z][0-9]\-_
|
||||
*
|
||||
* @package ParagonIE\ConstantTime
|
||||
*/
|
||||
@@ -43,7 +44,7 @@ abstract class Base64UrlSafe extends \WPMailSMTP\Vendor\ParagonIE\ConstantTime\B
|
||||
* @param int $src
|
||||
* @return int
|
||||
*/
|
||||
protected static function decode6Bits($src)
|
||||
protected static function decode6Bits(int $src) : int
|
||||
{
|
||||
$ret = -1;
|
||||
// if ($src > 0x40 && $src < 0x5b) $ret += $src - 0x41 + 1; // -64
|
||||
@@ -65,7 +66,7 @@ abstract class Base64UrlSafe extends \WPMailSMTP\Vendor\ParagonIE\ConstantTime\B
|
||||
* @param int $src
|
||||
* @return string
|
||||
*/
|
||||
protected static function encode6Bits($src)
|
||||
protected static function encode6Bits(int $src) : string
|
||||
{
|
||||
$diff = 0x41;
|
||||
// if ($src > 25) $diff += 0x61 - 0x41 - 26; // 6
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace WPMailSMTP\Vendor\ParagonIE\ConstantTime;
|
||||
|
||||
use TypeError;
|
||||
/**
|
||||
* Copyright (c) 2016 - 2017 Paragon Initiative Enterprises.
|
||||
* Copyright (c) 2016 - 2022 Paragon Initiative Enterprises.
|
||||
* Copyright (c) 2014 Steve "Sc00bz" Thomas (steve at tobtu dot com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
@@ -42,10 +44,12 @@ abstract class Binary
|
||||
* @param string $str
|
||||
* @return int
|
||||
*/
|
||||
public static function safeStrlen($str)
|
||||
public static function safeStrlen(string $str) : int
|
||||
{
|
||||
if (\function_exists('mb_strlen')) {
|
||||
return \mb_strlen($str, '8bit');
|
||||
// mb_strlen in PHP 7.x can return false.
|
||||
/** @psalm-suppress RedundantCast */
|
||||
return (int) \mb_strlen($str, '8bit');
|
||||
} else {
|
||||
return \strlen($str);
|
||||
}
|
||||
@@ -58,33 +62,21 @@ abstract class Binary
|
||||
* @staticvar boolean $exists
|
||||
* @param string $str
|
||||
* @param int $start
|
||||
* @param int $length
|
||||
* @param ?int $length
|
||||
* @return string
|
||||
* @throws \TypeError
|
||||
*
|
||||
* @throws TypeError
|
||||
*/
|
||||
public static function safeSubstr($str, $start = 0, $length = \null)
|
||||
public static function safeSubstr(string $str, int $start = 0, $length = null) : string
|
||||
{
|
||||
if (\function_exists('mb_substr')) {
|
||||
// mb_substr($str, 0, null, '8bit') returns an empty string on PHP
|
||||
// 5.3, so we have to find the length ourselves.
|
||||
if (\is_null($length)) {
|
||||
if ($start >= 0) {
|
||||
$length = self::safeStrlen($str) - $start;
|
||||
} else {
|
||||
$length = -$start;
|
||||
}
|
||||
}
|
||||
// $length calculation above might result in a 0-length string
|
||||
if ($length === 0) {
|
||||
return '';
|
||||
}
|
||||
return \mb_substr($str, $start, $length, '8bit');
|
||||
}
|
||||
if ($length === 0) {
|
||||
return '';
|
||||
}
|
||||
// Unlike mb_substr(), substr() doesn't accept null for length
|
||||
if (!\is_null($length)) {
|
||||
if (\function_exists('mb_substr')) {
|
||||
return \mb_substr($str, $start, $length, '8bit');
|
||||
}
|
||||
// Unlike mb_substr(), substr() doesn't accept NULL for length
|
||||
if ($length !== null) {
|
||||
return \substr($str, $start, $length);
|
||||
} else {
|
||||
return \substr($str, $start);
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace WPMailSMTP\Vendor\ParagonIE\ConstantTime;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2016 - 2017 Paragon Initiative Enterprises.
|
||||
* Copyright (c) 2016 - 2022 Paragon Initiative Enterprises.
|
||||
* Copyright (c) 2014 Steve "Sc00bz" Thomas (steve at tobtu dot com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
@@ -34,16 +35,17 @@ interface EncoderInterface
|
||||
* Convert a binary string into a hexadecimal string without cache-timing
|
||||
* leaks
|
||||
*
|
||||
* @param string $bin_string (raw binary)
|
||||
* @param string $binString (raw binary)
|
||||
* @return string
|
||||
*/
|
||||
public static function encode($bin_string);
|
||||
public static function encode(string $binString) : string;
|
||||
/**
|
||||
* Convert a binary string into a hexadecimal string without cache-timing
|
||||
* leaks
|
||||
*
|
||||
* @param string $encoded_string
|
||||
* @param string $encodedString
|
||||
* @param bool $strictPadding Error on invalid padding
|
||||
* @return string (raw binary)
|
||||
*/
|
||||
public static function decode($encoded_string);
|
||||
public static function decode(string $encodedString, bool $strictPadding = \false) : string;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace WPMailSMTP\Vendor\ParagonIE\ConstantTime;
|
||||
|
||||
use TypeError;
|
||||
/**
|
||||
* Copyright (c) 2016 - 2017 Paragon Initiative Enterprises.
|
||||
* Copyright (c) 2016 - 2022 Paragon Initiative Enterprises.
|
||||
* Copyright (c) 2014 Steve "Sc00bz" Thomas (steve at tobtu dot com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
@@ -35,8 +37,9 @@ abstract class Encoding
|
||||
*
|
||||
* @param string $str
|
||||
* @return string
|
||||
* @throws TypeError
|
||||
*/
|
||||
public static function base32Encode($str)
|
||||
public static function base32Encode(string $str) : string
|
||||
{
|
||||
return \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Base32::encode($str);
|
||||
}
|
||||
@@ -45,8 +48,9 @@ abstract class Encoding
|
||||
*
|
||||
* @param string $str
|
||||
* @return string
|
||||
* @throws TypeError
|
||||
*/
|
||||
public static function base32EncodeUpper($str)
|
||||
public static function base32EncodeUpper(string $str) : string
|
||||
{
|
||||
return \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Base32::encodeUpper($str);
|
||||
}
|
||||
@@ -55,8 +59,9 @@ abstract class Encoding
|
||||
*
|
||||
* @param string $str
|
||||
* @return string
|
||||
* @throws TypeError
|
||||
*/
|
||||
public static function base32Decode($str)
|
||||
public static function base32Decode(string $str) : string
|
||||
{
|
||||
return \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Base32::decode($str);
|
||||
}
|
||||
@@ -65,8 +70,9 @@ abstract class Encoding
|
||||
*
|
||||
* @param string $str
|
||||
* @return string
|
||||
* @throws TypeError
|
||||
*/
|
||||
public static function base32DecodeUpper($str)
|
||||
public static function base32DecodeUpper(string $str) : string
|
||||
{
|
||||
return \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Base32::decodeUpper($str);
|
||||
}
|
||||
@@ -75,38 +81,42 @@ abstract class Encoding
|
||||
*
|
||||
* @param string $str
|
||||
* @return string
|
||||
* @throws TypeError
|
||||
*/
|
||||
public static function base32HexEncode($str)
|
||||
public static function base32HexEncode(string $str) : string
|
||||
{
|
||||
return \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Base32Hex::encode($str);
|
||||
}
|
||||
/**
|
||||
* RFC 4648 Base32 encoding
|
||||
* RFC 4648 Base32Hex encoding
|
||||
*
|
||||
* @param string $str
|
||||
* @return string
|
||||
* @throws TypeError
|
||||
*/
|
||||
public static function base32HexEncodeUpper($str)
|
||||
public static function base32HexEncodeUpper(string $str) : string
|
||||
{
|
||||
return \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Base32Hex::encodeUpper($str);
|
||||
}
|
||||
/**
|
||||
* RFC 4648 Base32 decoding
|
||||
* RFC 4648 Base32Hex decoding
|
||||
*
|
||||
* @param string $str
|
||||
* @return string
|
||||
* @throws TypeError
|
||||
*/
|
||||
public static function base32HexDecode($str)
|
||||
public static function base32HexDecode(string $str) : string
|
||||
{
|
||||
return \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Base32Hex::decode($str);
|
||||
}
|
||||
/**
|
||||
* RFC 4648 Base32 decoding
|
||||
* RFC 4648 Base32Hex decoding
|
||||
*
|
||||
* @param string $str
|
||||
* @return string
|
||||
* @throws TypeError
|
||||
*/
|
||||
public static function base32HexDecodeUpper($str)
|
||||
public static function base32HexDecodeUpper(string $str) : string
|
||||
{
|
||||
return \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Base32Hex::decodeUpper($str);
|
||||
}
|
||||
@@ -115,18 +125,20 @@ abstract class Encoding
|
||||
*
|
||||
* @param string $str
|
||||
* @return string
|
||||
* @throws TypeError
|
||||
*/
|
||||
public static function base64Encode($str)
|
||||
public static function base64Encode(string $str) : string
|
||||
{
|
||||
return \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Base64::encode($str);
|
||||
}
|
||||
/**
|
||||
* RFC 4648 Base32 decoding
|
||||
* RFC 4648 Base64 decoding
|
||||
*
|
||||
* @param string $str
|
||||
* @return string
|
||||
* @throws TypeError
|
||||
*/
|
||||
public static function base64Decode($str)
|
||||
public static function base64Decode(string $str) : string
|
||||
{
|
||||
return \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Base64::decode($str);
|
||||
}
|
||||
@@ -134,49 +146,53 @@ abstract class Encoding
|
||||
* Encode into Base64
|
||||
*
|
||||
* Base64 character set "./[A-Z][a-z][0-9]"
|
||||
* @param string $src
|
||||
* @param string $str
|
||||
* @return string
|
||||
* @throws TypeError
|
||||
*/
|
||||
public static function base64EncodeDotSlash($src)
|
||||
public static function base64EncodeDotSlash(string $str) : string
|
||||
{
|
||||
return \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Base64DotSlash::encode($src);
|
||||
return \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Base64DotSlash::encode($str);
|
||||
}
|
||||
/**
|
||||
* Decode from base64 to raw binary
|
||||
*
|
||||
* Base64 character set "./[A-Z][a-z][0-9]"
|
||||
*
|
||||
* @param string $src
|
||||
* @param string $str
|
||||
* @return string
|
||||
* @throws \RangeException
|
||||
* @throws TypeError
|
||||
*/
|
||||
public static function base64DecodeDotSlash($src)
|
||||
public static function base64DecodeDotSlash(string $str) : string
|
||||
{
|
||||
return \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Base64DotSlash::decode($src);
|
||||
return \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Base64DotSlash::decode($str);
|
||||
}
|
||||
/**
|
||||
* Encode into Base64
|
||||
*
|
||||
* Base64 character set "[.-9][A-Z][a-z]" or "./[0-9][A-Z][a-z]"
|
||||
* @param string $src
|
||||
* @param string $str
|
||||
* @return string
|
||||
* @throws TypeError
|
||||
*/
|
||||
public static function base64EncodeDotSlashOrdered($src)
|
||||
public static function base64EncodeDotSlashOrdered(string $str) : string
|
||||
{
|
||||
return \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Base64DotSlashOrdered::encode($src);
|
||||
return \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Base64DotSlashOrdered::encode($str);
|
||||
}
|
||||
/**
|
||||
* Decode from base64 to raw binary
|
||||
*
|
||||
* Base64 character set "[.-9][A-Z][a-z]" or "./[0-9][A-Z][a-z]"
|
||||
*
|
||||
* @param string $src
|
||||
* @param string $str
|
||||
* @return string
|
||||
* @throws \RangeException
|
||||
* @throws TypeError
|
||||
*/
|
||||
public static function base64DecodeDotSlashOrdered($src)
|
||||
public static function base64DecodeDotSlashOrdered(string $str) : string
|
||||
{
|
||||
return \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Base64DotSlashOrdered::decode($src);
|
||||
return \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Base64DotSlashOrdered::decode($str);
|
||||
}
|
||||
/**
|
||||
* Convert a binary string into a hexadecimal string without cache-timing
|
||||
@@ -184,8 +200,9 @@ abstract class Encoding
|
||||
*
|
||||
* @param string $bin_string (raw binary)
|
||||
* @return string
|
||||
* @throws TypeError
|
||||
*/
|
||||
public static function hexEncode($bin_string)
|
||||
public static function hexEncode(string $bin_string) : string
|
||||
{
|
||||
return \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Hex::encode($bin_string);
|
||||
}
|
||||
@@ -197,7 +214,7 @@ abstract class Encoding
|
||||
* @return string (raw binary)
|
||||
* @throws \RangeException
|
||||
*/
|
||||
public static function hexDecode($hex_string)
|
||||
public static function hexDecode(string $hex_string) : string
|
||||
{
|
||||
return \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Hex::decode($hex_string);
|
||||
}
|
||||
@@ -207,8 +224,9 @@ abstract class Encoding
|
||||
*
|
||||
* @param string $bin_string (raw binary)
|
||||
* @return string
|
||||
* @throws TypeError
|
||||
*/
|
||||
public static function hexEncodeUpper($bin_string)
|
||||
public static function hexEncodeUpper(string $bin_string) : string
|
||||
{
|
||||
return \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Hex::encodeUpper($bin_string);
|
||||
}
|
||||
@@ -219,7 +237,7 @@ abstract class Encoding
|
||||
* @param string $bin_string (raw binary)
|
||||
* @return string
|
||||
*/
|
||||
public static function hexDecodeUpper($bin_string)
|
||||
public static function hexDecodeUpper(string $bin_string) : string
|
||||
{
|
||||
return \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Hex::decode($bin_string);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace WPMailSMTP\Vendor\ParagonIE\ConstantTime;
|
||||
|
||||
use RangeException;
|
||||
use TypeError;
|
||||
/**
|
||||
* Copyright (c) 2016 - 2017 Paragon Initiative Enterprises.
|
||||
* Copyright (c) 2016 - 2022 Paragon Initiative Enterprises.
|
||||
* Copyright (c) 2014 Steve "Sc00bz" Thomas (steve at tobtu dot com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
@@ -34,15 +37,17 @@ abstract class Hex implements \WPMailSMTP\Vendor\ParagonIE\ConstantTime\EncoderI
|
||||
* Convert a binary string into a hexadecimal string without cache-timing
|
||||
* leaks
|
||||
*
|
||||
* @param string $bin_string (raw binary)
|
||||
* @param string $binString (raw binary)
|
||||
* @return string
|
||||
* @throws TypeError
|
||||
*/
|
||||
public static function encode($bin_string)
|
||||
public static function encode(string $binString) : string
|
||||
{
|
||||
$hex = '';
|
||||
$len = \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Binary::safeStrlen($bin_string);
|
||||
$len = \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Binary::safeStrlen($binString);
|
||||
for ($i = 0; $i < $len; ++$i) {
|
||||
$chunk = \unpack('C', \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Binary::safeSubstr($bin_string, $i, 2));
|
||||
/** @var array<int, int> $chunk */
|
||||
$chunk = \unpack('C', $binString[$i]);
|
||||
$c = $chunk[1] & 0xf;
|
||||
$b = $chunk[1] >> 4;
|
||||
$hex .= \pack('CC', 87 + $b + ($b - 10 >> 8 & ~38), 87 + $c + ($c - 10 >> 8 & ~38));
|
||||
@@ -53,15 +58,17 @@ abstract class Hex implements \WPMailSMTP\Vendor\ParagonIE\ConstantTime\EncoderI
|
||||
* Convert a binary string into a hexadecimal string without cache-timing
|
||||
* leaks, returning uppercase letters (as per RFC 4648)
|
||||
*
|
||||
* @param string $bin_string (raw binary)
|
||||
* @param string $binString (raw binary)
|
||||
* @return string
|
||||
* @throws TypeError
|
||||
*/
|
||||
public static function encodeUpper($bin_string)
|
||||
public static function encodeUpper(string $binString) : string
|
||||
{
|
||||
$hex = '';
|
||||
$len = \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Binary::safeStrlen($bin_string);
|
||||
$len = \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Binary::safeStrlen($binString);
|
||||
for ($i = 0; $i < $len; ++$i) {
|
||||
$chunk = \unpack('C', \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Binary::safeSubstr($bin_string, $i, 2));
|
||||
/** @var array<int, int> $chunk */
|
||||
$chunk = \unpack('C', $binString[$i]);
|
||||
$c = $chunk[1] & 0xf;
|
||||
$b = $chunk[1] >> 4;
|
||||
$hex .= \pack('CC', 55 + $b + ($b - 10 >> 8 & ~6), 55 + $c + ($c - 10 >> 8 & ~6));
|
||||
@@ -72,21 +79,28 @@ abstract class Hex implements \WPMailSMTP\Vendor\ParagonIE\ConstantTime\EncoderI
|
||||
* Convert a hexadecimal string into a binary string without cache-timing
|
||||
* leaks
|
||||
*
|
||||
* @param string $encoded_string
|
||||
* @param string $encodedString
|
||||
* @param bool $strictPadding
|
||||
* @return string (raw binary)
|
||||
* @throws \RangeException
|
||||
* @throws RangeException
|
||||
*/
|
||||
public static function decode($encoded_string)
|
||||
public static function decode(string $encodedString, bool $strictPadding = \false) : string
|
||||
{
|
||||
$hex_pos = 0;
|
||||
$bin = '';
|
||||
$c_acc = 0;
|
||||
$hex_len = \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Binary::safeStrlen($encoded_string);
|
||||
$hex_len = \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Binary::safeStrlen($encodedString);
|
||||
$state = 0;
|
||||
if (($hex_len & 1) !== 0) {
|
||||
throw new \RangeException('Expected an even number of hexadecimal characters');
|
||||
if ($strictPadding) {
|
||||
throw new \RangeException('Expected an even number of hexadecimal characters');
|
||||
} else {
|
||||
$encodedString = '0' . $encodedString;
|
||||
++$hex_len;
|
||||
}
|
||||
}
|
||||
$chunk = \unpack('C*', $encoded_string);
|
||||
/** @var array<int, int> $chunk */
|
||||
$chunk = \unpack('C*', $encodedString);
|
||||
while ($hex_pos < $hex_len) {
|
||||
++$hex_pos;
|
||||
$c = $chunk[$hex_pos];
|
||||
@@ -95,7 +109,7 @@ abstract class Hex implements \WPMailSMTP\Vendor\ParagonIE\ConstantTime\EncoderI
|
||||
$c_alpha = ($c & ~32) - 55;
|
||||
$c_alpha0 = ($c_alpha - 10 ^ $c_alpha - 16) >> 8;
|
||||
if (($c_num0 | $c_alpha0) === 0) {
|
||||
throw new \RangeException('hexEncode() only expects hexadecimal characters');
|
||||
throw new \RangeException('Expected hexadecimal character');
|
||||
}
|
||||
$c_val = $c_num0 & $c_num | $c_alpha & $c_alpha0;
|
||||
if ($state === 0) {
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace WPMailSMTP\Vendor\ParagonIE\ConstantTime;
|
||||
|
||||
use TypeError;
|
||||
/**
|
||||
* Copyright (c) 2016 - 2017 Paragon Initiative Enterprises.
|
||||
* Copyright (c) 2016 - 2022 Paragon Initiative Enterprises.
|
||||
* Copyright (c) 2014 Steve "Sc00bz" Thomas (steve at tobtu dot com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
@@ -40,8 +42,10 @@ abstract class RFC4648
|
||||
*
|
||||
* @param string $str
|
||||
* @return string
|
||||
*
|
||||
* @throws TypeError
|
||||
*/
|
||||
public function base64Encode($str)
|
||||
public static function base64Encode(string $str) : string
|
||||
{
|
||||
return \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Base64::encode($str);
|
||||
}
|
||||
@@ -52,10 +56,12 @@ abstract class RFC4648
|
||||
*
|
||||
* @param string $str
|
||||
* @return string
|
||||
*
|
||||
* @throws TypeError
|
||||
*/
|
||||
public function base64Decode($str)
|
||||
public static function base64Decode(string $str) : string
|
||||
{
|
||||
return \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Base64::decode($str);
|
||||
return \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Base64::decode($str, \true);
|
||||
}
|
||||
/**
|
||||
* RFC 4648 Base64 (URL Safe) encoding
|
||||
@@ -64,8 +70,10 @@ abstract class RFC4648
|
||||
*
|
||||
* @param string $str
|
||||
* @return string
|
||||
*
|
||||
* @throws TypeError
|
||||
*/
|
||||
public function base64UrlSafeEncode($str)
|
||||
public static function base64UrlSafeEncode(string $str) : string
|
||||
{
|
||||
return \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Base64UrlSafe::encode($str);
|
||||
}
|
||||
@@ -76,10 +84,12 @@ abstract class RFC4648
|
||||
*
|
||||
* @param string $str
|
||||
* @return string
|
||||
*
|
||||
* @throws TypeError
|
||||
*/
|
||||
public function base64UrlSafeDecode($str)
|
||||
public static function base64UrlSafeDecode(string $str) : string
|
||||
{
|
||||
return \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Base64UrlSafe::decode($str);
|
||||
return \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Base64UrlSafe::decode($str, \true);
|
||||
}
|
||||
/**
|
||||
* RFC 4648 Base32 encoding
|
||||
@@ -88,8 +98,10 @@ abstract class RFC4648
|
||||
*
|
||||
* @param string $str
|
||||
* @return string
|
||||
*
|
||||
* @throws TypeError
|
||||
*/
|
||||
public function base32Encode($str)
|
||||
public static function base32Encode(string $str) : string
|
||||
{
|
||||
return \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Base32::encodeUpper($str);
|
||||
}
|
||||
@@ -100,10 +112,12 @@ abstract class RFC4648
|
||||
*
|
||||
* @param string $str
|
||||
* @return string
|
||||
*
|
||||
* @throws TypeError
|
||||
*/
|
||||
public function base32Decode($str)
|
||||
public static function base32Decode(string $str) : string
|
||||
{
|
||||
return \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Base32::decodeUpper($str);
|
||||
return \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Base32::decodeUpper($str, \true);
|
||||
}
|
||||
/**
|
||||
* RFC 4648 Base32-Hex encoding
|
||||
@@ -112,8 +126,10 @@ abstract class RFC4648
|
||||
*
|
||||
* @param string $str
|
||||
* @return string
|
||||
*
|
||||
* @throws TypeError
|
||||
*/
|
||||
public function base32HexEncode($str)
|
||||
public static function base32HexEncode(string $str) : string
|
||||
{
|
||||
return \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Base32::encodeUpper($str);
|
||||
}
|
||||
@@ -124,10 +140,12 @@ abstract class RFC4648
|
||||
*
|
||||
* @param string $str
|
||||
* @return string
|
||||
*
|
||||
* @throws TypeError
|
||||
*/
|
||||
public function base32HexDecode($str)
|
||||
public static function base32HexDecode(string $str) : string
|
||||
{
|
||||
return \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Base32::decodeUpper($str);
|
||||
return \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Base32::decodeUpper($str, \true);
|
||||
}
|
||||
/**
|
||||
* RFC 4648 Base16 decoding
|
||||
@@ -136,8 +154,10 @@ abstract class RFC4648
|
||||
*
|
||||
* @param string $str
|
||||
* @return string
|
||||
*
|
||||
* @throws TypeError
|
||||
*/
|
||||
public function base16Encode($str)
|
||||
public static function base16Encode(string $str) : string
|
||||
{
|
||||
return \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Hex::encodeUpper($str);
|
||||
}
|
||||
@@ -149,8 +169,8 @@ abstract class RFC4648
|
||||
* @param string $str
|
||||
* @return string
|
||||
*/
|
||||
public function base16Decode($str)
|
||||
public static function base16Decode(string $str) : string
|
||||
{
|
||||
return \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Hex::decode($str);
|
||||
return \WPMailSMTP\Vendor\ParagonIE\ConstantTime\Hex::decode($str, \true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,138 +1,558 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (c) 2014 TrueServer B.V.
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is furnished
|
||||
* to do so, subject to the following conditions:
|
||||
* (c) Fabien Potencier <fabien@symfony.com> and Trevor Rowbotham <trevor.rowbotham@pm.me>
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* Originally forked from
|
||||
* https://github.com/true/php-punycode/blob/v2.1.1/src/Punycode.php
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace WPMailSMTP\Vendor\Symfony\Polyfill\Intl\Idn;
|
||||
|
||||
use WPMailSMTP\Vendor\Symfony\Polyfill\Intl\Idn\Resources\unidata\DisallowedRanges;
|
||||
use WPMailSMTP\Vendor\Symfony\Polyfill\Intl\Idn\Resources\unidata\Regex;
|
||||
/**
|
||||
* Partial intl implementation in pure PHP.
|
||||
*
|
||||
* Implemented:
|
||||
* - idn_to_ascii - Convert domain name to IDNA ASCII form
|
||||
* - idn_to_utf8 - Convert domain name from IDNA ASCII to Unicode
|
||||
*
|
||||
* @author Renan Gonçalves <renan.saddam@gmail.com>
|
||||
* @author Sebastian Kroczek <sk@xbug.de>
|
||||
* @author Dmitry Lukashin <dmitry@lukashin.ru>
|
||||
* @author Laurent Bassin <laurent@bassin.info>
|
||||
* @see https://www.unicode.org/reports/tr46/
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
final class Idn
|
||||
{
|
||||
const INTL_IDNA_VARIANT_2003 = 0;
|
||||
const INTL_IDNA_VARIANT_UTS46 = 1;
|
||||
private static $encodeTable = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9');
|
||||
private static $decodeTable = array('a' => 0, 'b' => 1, 'c' => 2, 'd' => 3, 'e' => 4, 'f' => 5, 'g' => 6, 'h' => 7, 'i' => 8, 'j' => 9, 'k' => 10, 'l' => 11, 'm' => 12, 'n' => 13, 'o' => 14, 'p' => 15, 'q' => 16, 'r' => 17, 's' => 18, 't' => 19, 'u' => 20, 'v' => 21, 'w' => 22, 'x' => 23, 'y' => 24, 'z' => 25, '0' => 26, '1' => 27, '2' => 28, '3' => 29, '4' => 30, '5' => 31, '6' => 32, '7' => 33, '8' => 34, '9' => 35);
|
||||
public static function idn_to_ascii($domain, $options, $variant, &$idna_info = array())
|
||||
public const ERROR_EMPTY_LABEL = 1;
|
||||
public const ERROR_LABEL_TOO_LONG = 2;
|
||||
public const ERROR_DOMAIN_NAME_TOO_LONG = 4;
|
||||
public const ERROR_LEADING_HYPHEN = 8;
|
||||
public const ERROR_TRAILING_HYPHEN = 0x10;
|
||||
public const ERROR_HYPHEN_3_4 = 0x20;
|
||||
public const ERROR_LEADING_COMBINING_MARK = 0x40;
|
||||
public const ERROR_DISALLOWED = 0x80;
|
||||
public const ERROR_PUNYCODE = 0x100;
|
||||
public const ERROR_LABEL_HAS_DOT = 0x200;
|
||||
public const ERROR_INVALID_ACE_LABEL = 0x400;
|
||||
public const ERROR_BIDI = 0x800;
|
||||
public const ERROR_CONTEXTJ = 0x1000;
|
||||
public const ERROR_CONTEXTO_PUNCTUATION = 0x2000;
|
||||
public const ERROR_CONTEXTO_DIGITS = 0x4000;
|
||||
public const INTL_IDNA_VARIANT_2003 = 0;
|
||||
public const INTL_IDNA_VARIANT_UTS46 = 1;
|
||||
public const IDNA_DEFAULT = 0;
|
||||
public const IDNA_ALLOW_UNASSIGNED = 1;
|
||||
public const IDNA_USE_STD3_RULES = 2;
|
||||
public const IDNA_CHECK_BIDI = 4;
|
||||
public const IDNA_CHECK_CONTEXTJ = 8;
|
||||
public const IDNA_NONTRANSITIONAL_TO_ASCII = 16;
|
||||
public const IDNA_NONTRANSITIONAL_TO_UNICODE = 32;
|
||||
public const MAX_DOMAIN_SIZE = 253;
|
||||
public const MAX_LABEL_SIZE = 63;
|
||||
public const BASE = 36;
|
||||
public const TMIN = 1;
|
||||
public const TMAX = 26;
|
||||
public const SKEW = 38;
|
||||
public const DAMP = 700;
|
||||
public const INITIAL_BIAS = 72;
|
||||
public const INITIAL_N = 128;
|
||||
public const DELIMITER = '-';
|
||||
public const MAX_INT = 2147483647;
|
||||
/**
|
||||
* Contains the numeric value of a basic code point (for use in representing integers) in the
|
||||
* range 0 to BASE-1, or -1 if b is does not represent a value.
|
||||
*
|
||||
* @var array<int, int>
|
||||
*/
|
||||
private static $basicToDigit = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1];
|
||||
/**
|
||||
* @var array<int, int>
|
||||
*/
|
||||
private static $virama;
|
||||
/**
|
||||
* @var array<int, string>
|
||||
*/
|
||||
private static $mapped;
|
||||
/**
|
||||
* @var array<int, bool>
|
||||
*/
|
||||
private static $ignored;
|
||||
/**
|
||||
* @var array<int, string>
|
||||
*/
|
||||
private static $deviation;
|
||||
/**
|
||||
* @var array<int, bool>
|
||||
*/
|
||||
private static $disallowed;
|
||||
/**
|
||||
* @var array<int, string>
|
||||
*/
|
||||
private static $disallowed_STD3_mapped;
|
||||
/**
|
||||
* @var array<int, bool>
|
||||
*/
|
||||
private static $disallowed_STD3_valid;
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private static $mappingTableLoaded = \false;
|
||||
/**
|
||||
* @see https://www.unicode.org/reports/tr46/#ToASCII
|
||||
*
|
||||
* @param string $domainName
|
||||
* @param int $options
|
||||
* @param int $variant
|
||||
* @param array $idna_info
|
||||
*
|
||||
* @return string|false
|
||||
*/
|
||||
public static function idn_to_ascii($domainName, $options = self::IDNA_DEFAULT, $variant = self::INTL_IDNA_VARIANT_UTS46, &$idna_info = [])
|
||||
{
|
||||
if (\PHP_VERSION_ID >= 70200 && self::INTL_IDNA_VARIANT_2003 === $variant) {
|
||||
@\trigger_error('idn_to_ascii(): INTL_IDNA_VARIANT_2003 is deprecated', \E_USER_DEPRECATED);
|
||||
}
|
||||
if (self::INTL_IDNA_VARIANT_UTS46 === $variant) {
|
||||
$domain = \mb_strtolower($domain, 'utf-8');
|
||||
}
|
||||
$parts = \explode('.', $domain);
|
||||
foreach ($parts as $i => &$part) {
|
||||
if ('' === $part && \count($parts) > 1 + $i) {
|
||||
return \false;
|
||||
}
|
||||
if (\false === ($part = self::encodePart($part))) {
|
||||
return \false;
|
||||
$options = ['CheckHyphens' => \true, 'CheckBidi' => self::INTL_IDNA_VARIANT_2003 === $variant || 0 !== ($options & self::IDNA_CHECK_BIDI), 'CheckJoiners' => self::INTL_IDNA_VARIANT_UTS46 === $variant && 0 !== ($options & self::IDNA_CHECK_CONTEXTJ), 'UseSTD3ASCIIRules' => 0 !== ($options & self::IDNA_USE_STD3_RULES), 'Transitional_Processing' => self::INTL_IDNA_VARIANT_2003 === $variant || 0 === ($options & self::IDNA_NONTRANSITIONAL_TO_ASCII), 'VerifyDnsLength' => \true];
|
||||
$info = new \WPMailSMTP\Vendor\Symfony\Polyfill\Intl\Idn\Info();
|
||||
$labels = self::process((string) $domainName, $options, $info);
|
||||
foreach ($labels as $i => $label) {
|
||||
// Only convert labels to punycode that contain non-ASCII code points
|
||||
if (1 === \preg_match('/[^\\x00-\\x7F]/', $label)) {
|
||||
try {
|
||||
$label = 'xn--' . self::punycodeEncode($label);
|
||||
} catch (\Exception $e) {
|
||||
$info->errors |= self::ERROR_PUNYCODE;
|
||||
}
|
||||
$labels[$i] = $label;
|
||||
}
|
||||
}
|
||||
$output = \implode('.', $parts);
|
||||
$idna_info = array('result' => \strlen($output) > 255 ? \false : $output, 'isTransitionalDifferent' => \false, 'errors' => 0);
|
||||
return $idna_info['result'];
|
||||
if ($options['VerifyDnsLength']) {
|
||||
self::validateDomainAndLabelLength($labels, $info);
|
||||
}
|
||||
$idna_info = ['result' => \implode('.', $labels), 'isTransitionalDifferent' => $info->transitionalDifferent, 'errors' => $info->errors];
|
||||
return 0 === $info->errors ? $idna_info['result'] : \false;
|
||||
}
|
||||
public static function idn_to_utf8($domain, $options, $variant, &$idna_info = array())
|
||||
/**
|
||||
* @see https://www.unicode.org/reports/tr46/#ToUnicode
|
||||
*
|
||||
* @param string $domainName
|
||||
* @param int $options
|
||||
* @param int $variant
|
||||
* @param array $idna_info
|
||||
*
|
||||
* @return string|false
|
||||
*/
|
||||
public static function idn_to_utf8($domainName, $options = self::IDNA_DEFAULT, $variant = self::INTL_IDNA_VARIANT_UTS46, &$idna_info = [])
|
||||
{
|
||||
if (\PHP_VERSION_ID >= 70200 && self::INTL_IDNA_VARIANT_2003 === $variant) {
|
||||
@\trigger_error('idn_to_utf8(): INTL_IDNA_VARIANT_2003 is deprecated', \E_USER_DEPRECATED);
|
||||
}
|
||||
$parts = \explode('.', $domain);
|
||||
foreach ($parts as &$part) {
|
||||
$length = \strlen($part);
|
||||
if ($length < 1 || 63 < $length) {
|
||||
continue;
|
||||
}
|
||||
if (0 !== \strpos($part, 'xn--')) {
|
||||
continue;
|
||||
}
|
||||
$part = \substr($part, 4);
|
||||
$part = self::decodePart($part);
|
||||
}
|
||||
$output = \implode('.', $parts);
|
||||
$idna_info = array('result' => \strlen($output) > 255 ? \false : $output, 'isTransitionalDifferent' => \false, 'errors' => 0);
|
||||
return $idna_info['result'];
|
||||
$info = new \WPMailSMTP\Vendor\Symfony\Polyfill\Intl\Idn\Info();
|
||||
$labels = self::process((string) $domainName, ['CheckHyphens' => \true, 'CheckBidi' => self::INTL_IDNA_VARIANT_2003 === $variant || 0 !== ($options & self::IDNA_CHECK_BIDI), 'CheckJoiners' => self::INTL_IDNA_VARIANT_UTS46 === $variant && 0 !== ($options & self::IDNA_CHECK_CONTEXTJ), 'UseSTD3ASCIIRules' => 0 !== ($options & self::IDNA_USE_STD3_RULES), 'Transitional_Processing' => self::INTL_IDNA_VARIANT_2003 === $variant || 0 === ($options & self::IDNA_NONTRANSITIONAL_TO_UNICODE)], $info);
|
||||
$idna_info = ['result' => \implode('.', $labels), 'isTransitionalDifferent' => $info->transitionalDifferent, 'errors' => $info->errors];
|
||||
return 0 === $info->errors ? $idna_info['result'] : \false;
|
||||
}
|
||||
private static function encodePart($input)
|
||||
/**
|
||||
* @param string $label
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private static function isValidContextJ(array $codePoints, $label)
|
||||
{
|
||||
if (\substr($input, 0, 1) === '-' || \substr($input, -1) === '-') {
|
||||
if (!isset(self::$virama)) {
|
||||
self::$virama = (require __DIR__ . \DIRECTORY_SEPARATOR . 'Resources' . \DIRECTORY_SEPARATOR . 'unidata' . \DIRECTORY_SEPARATOR . 'virama.php');
|
||||
}
|
||||
$offset = 0;
|
||||
foreach ($codePoints as $i => $codePoint) {
|
||||
if (0x200c !== $codePoint && 0x200d !== $codePoint) {
|
||||
continue;
|
||||
}
|
||||
if (!isset($codePoints[$i - 1])) {
|
||||
return \false;
|
||||
}
|
||||
// If Canonical_Combining_Class(Before(cp)) .eq. Virama Then True;
|
||||
if (isset(self::$virama[$codePoints[$i - 1]])) {
|
||||
continue;
|
||||
}
|
||||
// If RegExpMatch((Joining_Type:{L,D})(Joining_Type:T)*\u200C(Joining_Type:T)*(Joining_Type:{R,D})) Then
|
||||
// True;
|
||||
// Generated RegExp = ([Joining_Type:{L,D}][Joining_Type:T]*\u200C[Joining_Type:T]*)[Joining_Type:{R,D}]
|
||||
if (0x200c === $codePoint && 1 === \preg_match(\WPMailSMTP\Vendor\Symfony\Polyfill\Intl\Idn\Resources\unidata\Regex::ZWNJ, $label, $matches, \PREG_OFFSET_CAPTURE, $offset)) {
|
||||
$offset += \strlen($matches[1][0]);
|
||||
continue;
|
||||
}
|
||||
return \false;
|
||||
}
|
||||
$codePoints = self::listCodePoints($input);
|
||||
$n = 128;
|
||||
$bias = 72;
|
||||
$delta = 0;
|
||||
$h = $b = \count($codePoints['basic']);
|
||||
$output = '';
|
||||
foreach ($codePoints['basic'] as $code) {
|
||||
$output .= \mb_chr($code, 'utf-8');
|
||||
return \true;
|
||||
}
|
||||
/**
|
||||
* @see https://www.unicode.org/reports/tr46/#ProcessingStepMap
|
||||
*
|
||||
* @param string $input
|
||||
* @param array<string, bool> $options
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private static function mapCodePoints($input, array $options, \WPMailSMTP\Vendor\Symfony\Polyfill\Intl\Idn\Info $info)
|
||||
{
|
||||
$str = '';
|
||||
$useSTD3ASCIIRules = $options['UseSTD3ASCIIRules'];
|
||||
$transitional = $options['Transitional_Processing'];
|
||||
foreach (self::utf8Decode($input) as $codePoint) {
|
||||
$data = self::lookupCodePointStatus($codePoint, $useSTD3ASCIIRules);
|
||||
switch ($data['status']) {
|
||||
case 'disallowed':
|
||||
$info->errors |= self::ERROR_DISALLOWED;
|
||||
// no break.
|
||||
case 'valid':
|
||||
$str .= \mb_chr($codePoint, 'utf-8');
|
||||
break;
|
||||
case 'ignored':
|
||||
// Do nothing.
|
||||
break;
|
||||
case 'mapped':
|
||||
$str .= $data['mapping'];
|
||||
break;
|
||||
case 'deviation':
|
||||
$info->transitionalDifferent = \true;
|
||||
$str .= $transitional ? $data['mapping'] : \mb_chr($codePoint, 'utf-8');
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($input === $output) {
|
||||
return $output;
|
||||
return $str;
|
||||
}
|
||||
/**
|
||||
* @see https://www.unicode.org/reports/tr46/#Processing
|
||||
*
|
||||
* @param string $domain
|
||||
* @param array<string, bool> $options
|
||||
*
|
||||
* @return array<int, string>
|
||||
*/
|
||||
private static function process($domain, array $options, \WPMailSMTP\Vendor\Symfony\Polyfill\Intl\Idn\Info $info)
|
||||
{
|
||||
// If VerifyDnsLength is not set, we are doing ToUnicode otherwise we are doing ToASCII and
|
||||
// we need to respect the VerifyDnsLength option.
|
||||
$checkForEmptyLabels = !isset($options['VerifyDnsLength']) || $options['VerifyDnsLength'];
|
||||
if ($checkForEmptyLabels && '' === $domain) {
|
||||
$info->errors |= self::ERROR_EMPTY_LABEL;
|
||||
return [$domain];
|
||||
}
|
||||
// Step 1. Map each code point in the domain name string
|
||||
$domain = self::mapCodePoints($domain, $options, $info);
|
||||
// Step 2. Normalize the domain name string to Unicode Normalization Form C.
|
||||
if (!\Normalizer::isNormalized($domain, \Normalizer::FORM_C)) {
|
||||
$domain = \Normalizer::normalize($domain, \Normalizer::FORM_C);
|
||||
}
|
||||
// Step 3. Break the string into labels at U+002E (.) FULL STOP.
|
||||
$labels = \explode('.', $domain);
|
||||
$lastLabelIndex = \count($labels) - 1;
|
||||
// Step 4. Convert and validate each label in the domain name string.
|
||||
foreach ($labels as $i => $label) {
|
||||
$validationOptions = $options;
|
||||
if ('xn--' === \substr($label, 0, 4)) {
|
||||
try {
|
||||
$label = self::punycodeDecode(\substr($label, 4));
|
||||
} catch (\Exception $e) {
|
||||
$info->errors |= self::ERROR_PUNYCODE;
|
||||
continue;
|
||||
}
|
||||
$validationOptions['Transitional_Processing'] = \false;
|
||||
$labels[$i] = $label;
|
||||
}
|
||||
self::validateLabel($label, $info, $validationOptions, $i > 0 && $i === $lastLabelIndex);
|
||||
}
|
||||
if ($info->bidiDomain && !$info->validBidiDomain) {
|
||||
$info->errors |= self::ERROR_BIDI;
|
||||
}
|
||||
// Any input domain name string that does not record an error has been successfully
|
||||
// processed according to this specification. Conversely, if an input domain_name string
|
||||
// causes an error, then the processing of the input domain_name string fails. Determining
|
||||
// what to do with error input is up to the caller, and not in the scope of this document.
|
||||
return $labels;
|
||||
}
|
||||
/**
|
||||
* @see https://tools.ietf.org/html/rfc5893#section-2
|
||||
*
|
||||
* @param string $label
|
||||
*/
|
||||
private static function validateBidiLabel($label, \WPMailSMTP\Vendor\Symfony\Polyfill\Intl\Idn\Info $info)
|
||||
{
|
||||
if (1 === \preg_match(\WPMailSMTP\Vendor\Symfony\Polyfill\Intl\Idn\Resources\unidata\Regex::RTL_LABEL, $label)) {
|
||||
$info->bidiDomain = \true;
|
||||
// Step 1. The first character must be a character with Bidi property L, R, or AL.
|
||||
// If it has the R or AL property, it is an RTL label
|
||||
if (1 !== \preg_match(\WPMailSMTP\Vendor\Symfony\Polyfill\Intl\Idn\Resources\unidata\Regex::BIDI_STEP_1_RTL, $label)) {
|
||||
$info->validBidiDomain = \false;
|
||||
return;
|
||||
}
|
||||
// Step 2. In an RTL label, only characters with the Bidi properties R, AL, AN, EN, ES,
|
||||
// CS, ET, ON, BN, or NSM are allowed.
|
||||
if (1 === \preg_match(\WPMailSMTP\Vendor\Symfony\Polyfill\Intl\Idn\Resources\unidata\Regex::BIDI_STEP_2, $label)) {
|
||||
$info->validBidiDomain = \false;
|
||||
return;
|
||||
}
|
||||
// Step 3. In an RTL label, the end of the label must be a character with Bidi property
|
||||
// R, AL, EN, or AN, followed by zero or more characters with Bidi property NSM.
|
||||
if (1 !== \preg_match(\WPMailSMTP\Vendor\Symfony\Polyfill\Intl\Idn\Resources\unidata\Regex::BIDI_STEP_3, $label)) {
|
||||
$info->validBidiDomain = \false;
|
||||
return;
|
||||
}
|
||||
// Step 4. In an RTL label, if an EN is present, no AN may be present, and vice versa.
|
||||
if (1 === \preg_match(\WPMailSMTP\Vendor\Symfony\Polyfill\Intl\Idn\Resources\unidata\Regex::BIDI_STEP_4_AN, $label) && 1 === \preg_match(\WPMailSMTP\Vendor\Symfony\Polyfill\Intl\Idn\Resources\unidata\Regex::BIDI_STEP_4_EN, $label)) {
|
||||
$info->validBidiDomain = \false;
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
// We are a LTR label
|
||||
// Step 1. The first character must be a character with Bidi property L, R, or AL.
|
||||
// If it has the L property, it is an LTR label.
|
||||
if (1 !== \preg_match(\WPMailSMTP\Vendor\Symfony\Polyfill\Intl\Idn\Resources\unidata\Regex::BIDI_STEP_1_LTR, $label)) {
|
||||
$info->validBidiDomain = \false;
|
||||
return;
|
||||
}
|
||||
// Step 5. In an LTR label, only characters with the Bidi properties L, EN,
|
||||
// ES, CS, ET, ON, BN, or NSM are allowed.
|
||||
if (1 === \preg_match(\WPMailSMTP\Vendor\Symfony\Polyfill\Intl\Idn\Resources\unidata\Regex::BIDI_STEP_5, $label)) {
|
||||
$info->validBidiDomain = \false;
|
||||
return;
|
||||
}
|
||||
// Step 6.In an LTR label, the end of the label must be a character with Bidi property L or
|
||||
// EN, followed by zero or more characters with Bidi property NSM.
|
||||
if (1 !== \preg_match(\WPMailSMTP\Vendor\Symfony\Polyfill\Intl\Idn\Resources\unidata\Regex::BIDI_STEP_6, $label)) {
|
||||
$info->validBidiDomain = \false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param array<int, string> $labels
|
||||
*/
|
||||
private static function validateDomainAndLabelLength(array $labels, \WPMailSMTP\Vendor\Symfony\Polyfill\Intl\Idn\Info $info)
|
||||
{
|
||||
$maxDomainSize = self::MAX_DOMAIN_SIZE;
|
||||
$length = \count($labels);
|
||||
// Number of "." delimiters.
|
||||
$domainLength = $length - 1;
|
||||
// If the last label is empty and it is not the first label, then it is the root label.
|
||||
// Increase the max size by 1, making it 254, to account for the root label's "."
|
||||
// delimiter. This also means we don't need to check the last label's length for being too
|
||||
// long.
|
||||
if ($length > 1 && '' === $labels[$length - 1]) {
|
||||
++$maxDomainSize;
|
||||
--$length;
|
||||
}
|
||||
for ($i = 0; $i < $length; ++$i) {
|
||||
$bytes = \strlen($labels[$i]);
|
||||
$domainLength += $bytes;
|
||||
if ($bytes > self::MAX_LABEL_SIZE) {
|
||||
$info->errors |= self::ERROR_LABEL_TOO_LONG;
|
||||
}
|
||||
}
|
||||
if ($domainLength > $maxDomainSize) {
|
||||
$info->errors |= self::ERROR_DOMAIN_NAME_TOO_LONG;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @see https://www.unicode.org/reports/tr46/#Validity_Criteria
|
||||
*
|
||||
* @param string $label
|
||||
* @param array<string, bool> $options
|
||||
* @param bool $canBeEmpty
|
||||
*/
|
||||
private static function validateLabel($label, \WPMailSMTP\Vendor\Symfony\Polyfill\Intl\Idn\Info $info, array $options, $canBeEmpty)
|
||||
{
|
||||
if ('' === $label) {
|
||||
if (!$canBeEmpty && (!isset($options['VerifyDnsLength']) || $options['VerifyDnsLength'])) {
|
||||
$info->errors |= self::ERROR_EMPTY_LABEL;
|
||||
}
|
||||
return;
|
||||
}
|
||||
// Step 1. The label must be in Unicode Normalization Form C.
|
||||
if (!\Normalizer::isNormalized($label, \Normalizer::FORM_C)) {
|
||||
$info->errors |= self::ERROR_INVALID_ACE_LABEL;
|
||||
}
|
||||
$codePoints = self::utf8Decode($label);
|
||||
if ($options['CheckHyphens']) {
|
||||
// Step 2. If CheckHyphens, the label must not contain a U+002D HYPHEN-MINUS character
|
||||
// in both the thrid and fourth positions.
|
||||
if (isset($codePoints[2], $codePoints[3]) && 0x2d === $codePoints[2] && 0x2d === $codePoints[3]) {
|
||||
$info->errors |= self::ERROR_HYPHEN_3_4;
|
||||
}
|
||||
// Step 3. If CheckHyphens, the label must neither begin nor end with a U+002D
|
||||
// HYPHEN-MINUS character.
|
||||
if ('-' === \substr($label, 0, 1)) {
|
||||
$info->errors |= self::ERROR_LEADING_HYPHEN;
|
||||
}
|
||||
if ('-' === \substr($label, -1, 1)) {
|
||||
$info->errors |= self::ERROR_TRAILING_HYPHEN;
|
||||
}
|
||||
}
|
||||
// Step 4. The label must not contain a U+002E (.) FULL STOP.
|
||||
if (\false !== \strpos($label, '.')) {
|
||||
$info->errors |= self::ERROR_LABEL_HAS_DOT;
|
||||
}
|
||||
// Step 5. The label must not begin with a combining mark, that is: General_Category=Mark.
|
||||
if (1 === \preg_match(\WPMailSMTP\Vendor\Symfony\Polyfill\Intl\Idn\Resources\unidata\Regex::COMBINING_MARK, $label)) {
|
||||
$info->errors |= self::ERROR_LEADING_COMBINING_MARK;
|
||||
}
|
||||
// Step 6. Each code point in the label must only have certain status values according to
|
||||
// Section 5, IDNA Mapping Table:
|
||||
$transitional = $options['Transitional_Processing'];
|
||||
$useSTD3ASCIIRules = $options['UseSTD3ASCIIRules'];
|
||||
foreach ($codePoints as $codePoint) {
|
||||
$data = self::lookupCodePointStatus($codePoint, $useSTD3ASCIIRules);
|
||||
$status = $data['status'];
|
||||
if ('valid' === $status || !$transitional && 'deviation' === $status) {
|
||||
continue;
|
||||
}
|
||||
$info->errors |= self::ERROR_DISALLOWED;
|
||||
break;
|
||||
}
|
||||
// Step 7. If CheckJoiners, the label must satisify the ContextJ rules from Appendix A, in
|
||||
// The Unicode Code Points and Internationalized Domain Names for Applications (IDNA)
|
||||
// [IDNA2008].
|
||||
if ($options['CheckJoiners'] && !self::isValidContextJ($codePoints, $label)) {
|
||||
$info->errors |= self::ERROR_CONTEXTJ;
|
||||
}
|
||||
// Step 8. If CheckBidi, and if the domain name is a Bidi domain name, then the label must
|
||||
// satisfy all six of the numbered conditions in [IDNA2008] RFC 5893, Section 2.
|
||||
if ($options['CheckBidi'] && (!$info->bidiDomain || $info->validBidiDomain)) {
|
||||
self::validateBidiLabel($label, $info);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @see https://tools.ietf.org/html/rfc3492#section-6.2
|
||||
*
|
||||
* @param string $input
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private static function punycodeDecode($input)
|
||||
{
|
||||
$n = self::INITIAL_N;
|
||||
$out = 0;
|
||||
$i = 0;
|
||||
$bias = self::INITIAL_BIAS;
|
||||
$lastDelimIndex = \strrpos($input, self::DELIMITER);
|
||||
$b = \false === $lastDelimIndex ? 0 : $lastDelimIndex;
|
||||
$inputLength = \strlen($input);
|
||||
$output = [];
|
||||
$bytes = \array_map('ord', \str_split($input));
|
||||
for ($j = 0; $j < $b; ++$j) {
|
||||
if ($bytes[$j] > 0x7f) {
|
||||
throw new \Exception('Invalid input');
|
||||
}
|
||||
$output[$out++] = $input[$j];
|
||||
}
|
||||
if ($b > 0) {
|
||||
$output .= '-';
|
||||
++$b;
|
||||
}
|
||||
$codePoints['nonBasic'] = \array_unique($codePoints['nonBasic']);
|
||||
\sort($codePoints['nonBasic']);
|
||||
$i = 0;
|
||||
$length = \mb_strlen($input, 'utf-8');
|
||||
while ($h < $length) {
|
||||
$m = $codePoints['nonBasic'][$i++];
|
||||
for ($in = $b; $in < $inputLength; ++$out) {
|
||||
$oldi = $i;
|
||||
$w = 1;
|
||||
for ($k = self::BASE;; $k += self::BASE) {
|
||||
if ($in >= $inputLength) {
|
||||
throw new \Exception('Invalid input');
|
||||
}
|
||||
$digit = self::$basicToDigit[$bytes[$in++] & 0xff];
|
||||
if ($digit < 0) {
|
||||
throw new \Exception('Invalid input');
|
||||
}
|
||||
if ($digit > \intdiv(self::MAX_INT - $i, $w)) {
|
||||
throw new \Exception('Integer overflow');
|
||||
}
|
||||
$i += $digit * $w;
|
||||
if ($k <= $bias) {
|
||||
$t = self::TMIN;
|
||||
} elseif ($k >= $bias + self::TMAX) {
|
||||
$t = self::TMAX;
|
||||
} else {
|
||||
$t = $k - $bias;
|
||||
}
|
||||
if ($digit < $t) {
|
||||
break;
|
||||
}
|
||||
$baseMinusT = self::BASE - $t;
|
||||
if ($w > \intdiv(self::MAX_INT, $baseMinusT)) {
|
||||
throw new \Exception('Integer overflow');
|
||||
}
|
||||
$w *= $baseMinusT;
|
||||
}
|
||||
$outPlusOne = $out + 1;
|
||||
$bias = self::adaptBias($i - $oldi, $outPlusOne, 0 === $oldi);
|
||||
if (\intdiv($i, $outPlusOne) > self::MAX_INT - $n) {
|
||||
throw new \Exception('Integer overflow');
|
||||
}
|
||||
$n += \intdiv($i, $outPlusOne);
|
||||
$i %= $outPlusOne;
|
||||
\array_splice($output, $i++, 0, [\mb_chr($n, 'utf-8')]);
|
||||
}
|
||||
return \implode('', $output);
|
||||
}
|
||||
/**
|
||||
* @see https://tools.ietf.org/html/rfc3492#section-6.3
|
||||
*
|
||||
* @param string $input
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private static function punycodeEncode($input)
|
||||
{
|
||||
$n = self::INITIAL_N;
|
||||
$delta = 0;
|
||||
$out = 0;
|
||||
$bias = self::INITIAL_BIAS;
|
||||
$inputLength = 0;
|
||||
$output = '';
|
||||
$iter = self::utf8Decode($input);
|
||||
foreach ($iter as $codePoint) {
|
||||
++$inputLength;
|
||||
if ($codePoint < 0x80) {
|
||||
$output .= \chr($codePoint);
|
||||
++$out;
|
||||
}
|
||||
}
|
||||
$h = $out;
|
||||
$b = $out;
|
||||
if ($b > 0) {
|
||||
$output .= self::DELIMITER;
|
||||
++$out;
|
||||
}
|
||||
while ($h < $inputLength) {
|
||||
$m = self::MAX_INT;
|
||||
foreach ($iter as $codePoint) {
|
||||
if ($codePoint >= $n && $codePoint < $m) {
|
||||
$m = $codePoint;
|
||||
}
|
||||
}
|
||||
if ($m - $n > \intdiv(self::MAX_INT - $delta, $h + 1)) {
|
||||
throw new \Exception('Integer overflow');
|
||||
}
|
||||
$delta += ($m - $n) * ($h + 1);
|
||||
$n = $m;
|
||||
foreach ($codePoints['all'] as $c) {
|
||||
if ($c < $n || $c < 128) {
|
||||
++$delta;
|
||||
foreach ($iter as $codePoint) {
|
||||
if ($codePoint < $n && 0 === ++$delta) {
|
||||
throw new \Exception('Integer overflow');
|
||||
}
|
||||
if ($c === $n) {
|
||||
if ($codePoint === $n) {
|
||||
$q = $delta;
|
||||
for ($k = 36;; $k += 36) {
|
||||
$t = self::calculateThreshold($k, $bias);
|
||||
for ($k = self::BASE;; $k += self::BASE) {
|
||||
if ($k <= $bias) {
|
||||
$t = self::TMIN;
|
||||
} elseif ($k >= $bias + self::TMAX) {
|
||||
$t = self::TMAX;
|
||||
} else {
|
||||
$t = $k - $bias;
|
||||
}
|
||||
if ($q < $t) {
|
||||
break;
|
||||
}
|
||||
$code = $t + ($q - $t) % (36 - $t);
|
||||
$output .= self::$encodeTable[$code];
|
||||
$q = ($q - $t) / (36 - $t);
|
||||
$qMinusT = $q - $t;
|
||||
$baseMinusT = self::BASE - $t;
|
||||
$output .= self::encodeDigit($t + $qMinusT % $baseMinusT, \false);
|
||||
++$out;
|
||||
$q = \intdiv($qMinusT, $baseMinusT);
|
||||
}
|
||||
$output .= self::$encodeTable[$q];
|
||||
$bias = self::adapt($delta, $h + 1, $h === $b);
|
||||
$output .= self::encodeDigit($q, \false);
|
||||
++$out;
|
||||
$bias = self::adaptBias($delta, $h + 1, $h === $b);
|
||||
$delta = 0;
|
||||
++$h;
|
||||
}
|
||||
@@ -140,77 +560,156 @@ final class Idn
|
||||
++$delta;
|
||||
++$n;
|
||||
}
|
||||
$output = 'xn--' . $output;
|
||||
return \strlen($output) < 1 || 63 < \strlen($output) ? \false : \strtolower($output);
|
||||
return $output;
|
||||
}
|
||||
private static function listCodePoints($input)
|
||||
/**
|
||||
* @see https://tools.ietf.org/html/rfc3492#section-6.1
|
||||
*
|
||||
* @param int $delta
|
||||
* @param int $numPoints
|
||||
* @param bool $firstTime
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private static function adaptBias($delta, $numPoints, $firstTime)
|
||||
{
|
||||
$codePoints = array('all' => array(), 'basic' => array(), 'nonBasic' => array());
|
||||
$length = \mb_strlen($input, 'utf-8');
|
||||
// xxx >> 1 is a faster way of doing intdiv(xxx, 2)
|
||||
$delta = $firstTime ? \intdiv($delta, self::DAMP) : $delta >> 1;
|
||||
$delta += \intdiv($delta, $numPoints);
|
||||
$k = 0;
|
||||
while ($delta > (self::BASE - self::TMIN) * self::TMAX >> 1) {
|
||||
$delta = \intdiv($delta, self::BASE - self::TMIN);
|
||||
$k += self::BASE;
|
||||
}
|
||||
return $k + \intdiv((self::BASE - self::TMIN + 1) * $delta, $delta + self::SKEW);
|
||||
}
|
||||
/**
|
||||
* @param int $d
|
||||
* @param bool $flag
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private static function encodeDigit($d, $flag)
|
||||
{
|
||||
return \chr($d + 22 + 75 * ($d < 26 ? 1 : 0) - (($flag ? 1 : 0) << 5));
|
||||
}
|
||||
/**
|
||||
* Takes a UTF-8 encoded string and converts it into a series of integer code points. Any
|
||||
* invalid byte sequences will be replaced by a U+FFFD replacement code point.
|
||||
*
|
||||
* @see https://encoding.spec.whatwg.org/#utf-8-decoder
|
||||
*
|
||||
* @param string $input
|
||||
*
|
||||
* @return array<int, int>
|
||||
*/
|
||||
private static function utf8Decode($input)
|
||||
{
|
||||
$bytesSeen = 0;
|
||||
$bytesNeeded = 0;
|
||||
$lowerBoundary = 0x80;
|
||||
$upperBoundary = 0xbf;
|
||||
$codePoint = 0;
|
||||
$codePoints = [];
|
||||
$length = \strlen($input);
|
||||
for ($i = 0; $i < $length; ++$i) {
|
||||
$char = \mb_substr($input, $i, 1, 'utf-8');
|
||||
$code = \mb_ord($char, 'utf-8');
|
||||
if ($code < 128) {
|
||||
$codePoints['all'][] = $codePoints['basic'][] = $code;
|
||||
} else {
|
||||
$codePoints['all'][] = $codePoints['nonBasic'][] = $code;
|
||||
$byte = \ord($input[$i]);
|
||||
if (0 === $bytesNeeded) {
|
||||
if ($byte >= 0x0 && $byte <= 0x7f) {
|
||||
$codePoints[] = $byte;
|
||||
continue;
|
||||
}
|
||||
if ($byte >= 0xc2 && $byte <= 0xdf) {
|
||||
$bytesNeeded = 1;
|
||||
$codePoint = $byte & 0x1f;
|
||||
} elseif ($byte >= 0xe0 && $byte <= 0xef) {
|
||||
if (0xe0 === $byte) {
|
||||
$lowerBoundary = 0xa0;
|
||||
} elseif (0xed === $byte) {
|
||||
$upperBoundary = 0x9f;
|
||||
}
|
||||
$bytesNeeded = 2;
|
||||
$codePoint = $byte & 0xf;
|
||||
} elseif ($byte >= 0xf0 && $byte <= 0xf4) {
|
||||
if (0xf0 === $byte) {
|
||||
$lowerBoundary = 0x90;
|
||||
} elseif (0xf4 === $byte) {
|
||||
$upperBoundary = 0x8f;
|
||||
}
|
||||
$bytesNeeded = 3;
|
||||
$codePoint = $byte & 0x7;
|
||||
} else {
|
||||
$codePoints[] = 0xfffd;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if ($byte < $lowerBoundary || $byte > $upperBoundary) {
|
||||
$codePoint = 0;
|
||||
$bytesNeeded = 0;
|
||||
$bytesSeen = 0;
|
||||
$lowerBoundary = 0x80;
|
||||
$upperBoundary = 0xbf;
|
||||
--$i;
|
||||
$codePoints[] = 0xfffd;
|
||||
continue;
|
||||
}
|
||||
$lowerBoundary = 0x80;
|
||||
$upperBoundary = 0xbf;
|
||||
$codePoint = $codePoint << 6 | $byte & 0x3f;
|
||||
if (++$bytesSeen !== $bytesNeeded) {
|
||||
continue;
|
||||
}
|
||||
$codePoints[] = $codePoint;
|
||||
$codePoint = 0;
|
||||
$bytesNeeded = 0;
|
||||
$bytesSeen = 0;
|
||||
}
|
||||
// String unexpectedly ended, so append a U+FFFD code point.
|
||||
if (0 !== $bytesNeeded) {
|
||||
$codePoints[] = 0xfffd;
|
||||
}
|
||||
return $codePoints;
|
||||
}
|
||||
private static function calculateThreshold($k, $bias)
|
||||
/**
|
||||
* @param int $codePoint
|
||||
* @param bool $useSTD3ASCIIRules
|
||||
*
|
||||
* @return array{status: string, mapping?: string}
|
||||
*/
|
||||
private static function lookupCodePointStatus($codePoint, $useSTD3ASCIIRules)
|
||||
{
|
||||
if ($k <= $bias + 1) {
|
||||
return 1;
|
||||
if (!self::$mappingTableLoaded) {
|
||||
self::$mappingTableLoaded = \true;
|
||||
self::$mapped = (require __DIR__ . '/Resources/unidata/mapped.php');
|
||||
self::$ignored = (require __DIR__ . '/Resources/unidata/ignored.php');
|
||||
self::$deviation = (require __DIR__ . '/Resources/unidata/deviation.php');
|
||||
self::$disallowed = (require __DIR__ . '/Resources/unidata/disallowed.php');
|
||||
self::$disallowed_STD3_mapped = (require __DIR__ . '/Resources/unidata/disallowed_STD3_mapped.php');
|
||||
self::$disallowed_STD3_valid = (require __DIR__ . '/Resources/unidata/disallowed_STD3_valid.php');
|
||||
}
|
||||
if ($k >= $bias + 26) {
|
||||
return 26;
|
||||
if (isset(self::$mapped[$codePoint])) {
|
||||
return ['status' => 'mapped', 'mapping' => self::$mapped[$codePoint]];
|
||||
}
|
||||
return $k - $bias;
|
||||
}
|
||||
private static function adapt($delta, $numPoints, $firstTime)
|
||||
{
|
||||
$delta = (int) ($firstTime ? $delta / 700 : $delta / 2);
|
||||
$delta += (int) ($delta / $numPoints);
|
||||
$k = 0;
|
||||
while ($delta > 35 * 13) {
|
||||
$delta = (int) ($delta / 35);
|
||||
$k = $k + 36;
|
||||
if (isset(self::$ignored[$codePoint])) {
|
||||
return ['status' => 'ignored'];
|
||||
}
|
||||
return $k + (int) (36 * $delta / ($delta + 38));
|
||||
}
|
||||
private static function decodePart($input)
|
||||
{
|
||||
$n = 128;
|
||||
$i = 0;
|
||||
$bias = 72;
|
||||
$output = '';
|
||||
$pos = \strrpos($input, '-');
|
||||
if (\false !== $pos) {
|
||||
$output = \substr($input, 0, $pos++);
|
||||
} else {
|
||||
$pos = 0;
|
||||
if (isset(self::$deviation[$codePoint])) {
|
||||
return ['status' => 'deviation', 'mapping' => self::$deviation[$codePoint]];
|
||||
}
|
||||
$outputLength = \strlen($output);
|
||||
$inputLength = \strlen($input);
|
||||
while ($pos < $inputLength) {
|
||||
$oldi = $i;
|
||||
$w = 1;
|
||||
for ($k = 36;; $k += 36) {
|
||||
$digit = self::$decodeTable[$input[$pos++]];
|
||||
$i += $digit * $w;
|
||||
$t = self::calculateThreshold($k, $bias);
|
||||
if ($digit < $t) {
|
||||
break;
|
||||
}
|
||||
$w *= 36 - $t;
|
||||
if (isset(self::$disallowed[$codePoint]) || \WPMailSMTP\Vendor\Symfony\Polyfill\Intl\Idn\Resources\unidata\DisallowedRanges::inRange($codePoint)) {
|
||||
return ['status' => 'disallowed'];
|
||||
}
|
||||
$isDisallowedMapped = isset(self::$disallowed_STD3_mapped[$codePoint]);
|
||||
if ($isDisallowedMapped || isset(self::$disallowed_STD3_valid[$codePoint])) {
|
||||
$status = 'disallowed';
|
||||
if (!$useSTD3ASCIIRules) {
|
||||
$status = $isDisallowedMapped ? 'mapped' : 'valid';
|
||||
}
|
||||
$bias = self::adapt($i - $oldi, ++$outputLength, 0 === $oldi);
|
||||
$n = $n + (int) ($i / $outputLength);
|
||||
$i = $i % $outputLength;
|
||||
$output = \mb_substr($output, 0, $i, 'utf-8') . \mb_chr($n, 'utf-8') . \mb_substr($output, $i, $outputLength - 1, 'utf-8');
|
||||
++$i;
|
||||
if ($isDisallowedMapped) {
|
||||
return ['status' => $status, 'mapping' => self::$disallowed_STD3_mapped[$codePoint]];
|
||||
}
|
||||
return ['status' => $status];
|
||||
}
|
||||
return $output;
|
||||
return ['status' => 'valid'];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com> and Trevor Rowbotham <trevor.rowbotham@pm.me>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace WPMailSMTP\Vendor\Symfony\Polyfill\Intl\Idn;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class Info
|
||||
{
|
||||
public $bidiDomain = \false;
|
||||
public $errors = 0;
|
||||
public $validBidiDomain = \true;
|
||||
public $transitionalDifferent = \false;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2018-2019 Fabien Potencier
|
||||
Copyright (c) 2018-present Fabien Potencier and Trevor Rowbotham <trevor.rowbotham@pm.me>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -0,0 +1,294 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace WPMailSMTP\Vendor\Symfony\Polyfill\Intl\Idn\Resources\unidata;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class DisallowedRanges
|
||||
{
|
||||
/**
|
||||
* @param int $codePoint
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function inRange($codePoint)
|
||||
{
|
||||
if ($codePoint >= 128 && $codePoint <= 159) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 2155 && $codePoint <= 2207) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 3676 && $codePoint <= 3712) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 3808 && $codePoint <= 3839) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 4059 && $codePoint <= 4095) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 4256 && $codePoint <= 4293) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 6849 && $codePoint <= 6911) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 11859 && $codePoint <= 11903) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 42955 && $codePoint <= 42996) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 55296 && $codePoint <= 57343) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 57344 && $codePoint <= 63743) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 64218 && $codePoint <= 64255) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 64976 && $codePoint <= 65007) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 65630 && $codePoint <= 65663) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 65953 && $codePoint <= 65999) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 66046 && $codePoint <= 66175) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 66518 && $codePoint <= 66559) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 66928 && $codePoint <= 67071) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 67432 && $codePoint <= 67583) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 67760 && $codePoint <= 67807) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 67904 && $codePoint <= 67967) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 68256 && $codePoint <= 68287) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 68528 && $codePoint <= 68607) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 68681 && $codePoint <= 68735) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 68922 && $codePoint <= 69215) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 69298 && $codePoint <= 69375) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 69466 && $codePoint <= 69551) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 70207 && $codePoint <= 70271) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 70517 && $codePoint <= 70655) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 70874 && $codePoint <= 71039) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 71134 && $codePoint <= 71167) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 71370 && $codePoint <= 71423) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 71488 && $codePoint <= 71679) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 71740 && $codePoint <= 71839) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 72026 && $codePoint <= 72095) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 72441 && $codePoint <= 72703) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 72887 && $codePoint <= 72959) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 73130 && $codePoint <= 73439) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 73465 && $codePoint <= 73647) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 74650 && $codePoint <= 74751) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 75076 && $codePoint <= 77823) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 78905 && $codePoint <= 82943) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 83527 && $codePoint <= 92159) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 92784 && $codePoint <= 92879) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 93072 && $codePoint <= 93759) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 93851 && $codePoint <= 93951) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 94112 && $codePoint <= 94175) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 101590 && $codePoint <= 101631) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 101641 && $codePoint <= 110591) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 110879 && $codePoint <= 110927) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 111356 && $codePoint <= 113663) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 113828 && $codePoint <= 118783) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 119366 && $codePoint <= 119519) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 119673 && $codePoint <= 119807) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 121520 && $codePoint <= 122879) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 122923 && $codePoint <= 123135) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 123216 && $codePoint <= 123583) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 123648 && $codePoint <= 124927) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 125143 && $codePoint <= 125183) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 125280 && $codePoint <= 126064) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 126133 && $codePoint <= 126208) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 126270 && $codePoint <= 126463) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 126652 && $codePoint <= 126703) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 126706 && $codePoint <= 126975) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 127406 && $codePoint <= 127461) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 127590 && $codePoint <= 127743) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 129202 && $codePoint <= 129279) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 129751 && $codePoint <= 129791) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 129995 && $codePoint <= 130031) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 130042 && $codePoint <= 131069) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 173790 && $codePoint <= 173823) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 191457 && $codePoint <= 194559) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 195102 && $codePoint <= 196605) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 201547 && $codePoint <= 262141) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 262144 && $codePoint <= 327677) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 327680 && $codePoint <= 393213) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 393216 && $codePoint <= 458749) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 458752 && $codePoint <= 524285) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 524288 && $codePoint <= 589821) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 589824 && $codePoint <= 655357) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 655360 && $codePoint <= 720893) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 720896 && $codePoint <= 786429) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 786432 && $codePoint <= 851965) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 851968 && $codePoint <= 917501) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 917536 && $codePoint <= 917631) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 917632 && $codePoint <= 917759) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 918000 && $codePoint <= 983037) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 983040 && $codePoint <= 1048573) {
|
||||
return \true;
|
||||
}
|
||||
if ($codePoint >= 1048576 && $codePoint <= 1114109) {
|
||||
return \true;
|
||||
}
|
||||
return \false;
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Vendor;
|
||||
|
||||
return array(223 => 'ss', 962 => 'σ', 8204 => '', 8205 => '');
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Vendor;
|
||||
|
||||
return array(160 => ' ', 168 => ' ̈', 175 => ' ̄', 180 => ' ́', 184 => ' ̧', 728 => ' ̆', 729 => ' ̇', 730 => ' ̊', 731 => ' ̨', 732 => ' ̃', 733 => ' ̋', 890 => ' ι', 894 => ';', 900 => ' ́', 901 => ' ̈́', 8125 => ' ̓', 8127 => ' ̓', 8128 => ' ͂', 8129 => ' ̈͂', 8141 => ' ̓̀', 8142 => ' ̓́', 8143 => ' ̓͂', 8157 => ' ̔̀', 8158 => ' ̔́', 8159 => ' ̔͂', 8173 => ' ̈̀', 8174 => ' ̈́', 8175 => '`', 8189 => ' ́', 8190 => ' ̔', 8192 => ' ', 8193 => ' ', 8194 => ' ', 8195 => ' ', 8196 => ' ', 8197 => ' ', 8198 => ' ', 8199 => ' ', 8200 => ' ', 8201 => ' ', 8202 => ' ', 8215 => ' ̳', 8239 => ' ', 8252 => '!!', 8254 => ' ̅', 8263 => '??', 8264 => '?!', 8265 => '!?', 8287 => ' ', 8314 => '+', 8316 => '=', 8317 => '(', 8318 => ')', 8330 => '+', 8332 => '=', 8333 => '(', 8334 => ')', 8448 => 'a/c', 8449 => 'a/s', 8453 => 'c/o', 8454 => 'c/u', 9332 => '(1)', 9333 => '(2)', 9334 => '(3)', 9335 => '(4)', 9336 => '(5)', 9337 => '(6)', 9338 => '(7)', 9339 => '(8)', 9340 => '(9)', 9341 => '(10)', 9342 => '(11)', 9343 => '(12)', 9344 => '(13)', 9345 => '(14)', 9346 => '(15)', 9347 => '(16)', 9348 => '(17)', 9349 => '(18)', 9350 => '(19)', 9351 => '(20)', 9372 => '(a)', 9373 => '(b)', 9374 => '(c)', 9375 => '(d)', 9376 => '(e)', 9377 => '(f)', 9378 => '(g)', 9379 => '(h)', 9380 => '(i)', 9381 => '(j)', 9382 => '(k)', 9383 => '(l)', 9384 => '(m)', 9385 => '(n)', 9386 => '(o)', 9387 => '(p)', 9388 => '(q)', 9389 => '(r)', 9390 => '(s)', 9391 => '(t)', 9392 => '(u)', 9393 => '(v)', 9394 => '(w)', 9395 => '(x)', 9396 => '(y)', 9397 => '(z)', 10868 => '::=', 10869 => '==', 10870 => '===', 12288 => ' ', 12443 => ' ゙', 12444 => ' ゚', 12800 => '(ᄀ)', 12801 => '(ᄂ)', 12802 => '(ᄃ)', 12803 => '(ᄅ)', 12804 => '(ᄆ)', 12805 => '(ᄇ)', 12806 => '(ᄉ)', 12807 => '(ᄋ)', 12808 => '(ᄌ)', 12809 => '(ᄎ)', 12810 => '(ᄏ)', 12811 => '(ᄐ)', 12812 => '(ᄑ)', 12813 => '(ᄒ)', 12814 => '(가)', 12815 => '(나)', 12816 => '(다)', 12817 => '(라)', 12818 => '(마)', 12819 => '(바)', 12820 => '(사)', 12821 => '(아)', 12822 => '(자)', 12823 => '(차)', 12824 => '(카)', 12825 => '(타)', 12826 => '(파)', 12827 => '(하)', 12828 => '(주)', 12829 => '(오전)', 12830 => '(오후)', 12832 => '(一)', 12833 => '(二)', 12834 => '(三)', 12835 => '(四)', 12836 => '(五)', 12837 => '(六)', 12838 => '(七)', 12839 => '(八)', 12840 => '(九)', 12841 => '(十)', 12842 => '(月)', 12843 => '(火)', 12844 => '(水)', 12845 => '(木)', 12846 => '(金)', 12847 => '(土)', 12848 => '(日)', 12849 => '(株)', 12850 => '(有)', 12851 => '(社)', 12852 => '(名)', 12853 => '(特)', 12854 => '(財)', 12855 => '(祝)', 12856 => '(労)', 12857 => '(代)', 12858 => '(呼)', 12859 => '(学)', 12860 => '(監)', 12861 => '(企)', 12862 => '(資)', 12863 => '(協)', 12864 => '(祭)', 12865 => '(休)', 12866 => '(自)', 12867 => '(至)', 64297 => '+', 64606 => ' ٌّ', 64607 => ' ٍّ', 64608 => ' َّ', 64609 => ' ُّ', 64610 => ' ِّ', 64611 => ' ّٰ', 65018 => 'صلى الله عليه وسلم', 65019 => 'جل جلاله', 65040 => ',', 65043 => ':', 65044 => ';', 65045 => '!', 65046 => '?', 65075 => '_', 65076 => '_', 65077 => '(', 65078 => ')', 65079 => '{', 65080 => '}', 65095 => '[', 65096 => ']', 65097 => ' ̅', 65098 => ' ̅', 65099 => ' ̅', 65100 => ' ̅', 65101 => '_', 65102 => '_', 65103 => '_', 65104 => ',', 65108 => ';', 65109 => ':', 65110 => '?', 65111 => '!', 65113 => '(', 65114 => ')', 65115 => '{', 65116 => '}', 65119 => '#', 65120 => '&', 65121 => '*', 65122 => '+', 65124 => '<', 65125 => '>', 65126 => '=', 65128 => '\\', 65129 => '$', 65130 => '%', 65131 => '@', 65136 => ' ً', 65138 => ' ٌ', 65140 => ' ٍ', 65142 => ' َ', 65144 => ' ُ', 65146 => ' ِ', 65148 => ' ّ', 65150 => ' ْ', 65281 => '!', 65282 => '"', 65283 => '#', 65284 => '$', 65285 => '%', 65286 => '&', 65287 => '\'', 65288 => '(', 65289 => ')', 65290 => '*', 65291 => '+', 65292 => ',', 65295 => '/', 65306 => ':', 65307 => ';', 65308 => '<', 65309 => '=', 65310 => '>', 65311 => '?', 65312 => '@', 65339 => '[', 65340 => '\\', 65341 => ']', 65342 => '^', 65343 => '_', 65344 => '`', 65371 => '{', 65372 => '|', 65373 => '}', 65374 => '~', 65507 => ' ̄', 127233 => '0,', 127234 => '1,', 127235 => '2,', 127236 => '3,', 127237 => '4,', 127238 => '5,', 127239 => '6,', 127240 => '7,', 127241 => '8,', 127242 => '9,', 127248 => '(a)', 127249 => '(b)', 127250 => '(c)', 127251 => '(d)', 127252 => '(e)', 127253 => '(f)', 127254 => '(g)', 127255 => '(h)', 127256 => '(i)', 127257 => '(j)', 127258 => '(k)', 127259 => '(l)', 127260 => '(m)', 127261 => '(n)', 127262 => '(o)', 127263 => '(p)', 127264 => '(q)', 127265 => '(r)', 127266 => '(s)', 127267 => '(t)', 127268 => '(u)', 127269 => '(v)', 127270 => '(w)', 127271 => '(x)', 127272 => '(y)', 127273 => '(z)');
|
||||
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Vendor;
|
||||
|
||||
return array(0 => \true, 1 => \true, 2 => \true, 3 => \true, 4 => \true, 5 => \true, 6 => \true, 7 => \true, 8 => \true, 9 => \true, 10 => \true, 11 => \true, 12 => \true, 13 => \true, 14 => \true, 15 => \true, 16 => \true, 17 => \true, 18 => \true, 19 => \true, 20 => \true, 21 => \true, 22 => \true, 23 => \true, 24 => \true, 25 => \true, 26 => \true, 27 => \true, 28 => \true, 29 => \true, 30 => \true, 31 => \true, 32 => \true, 33 => \true, 34 => \true, 35 => \true, 36 => \true, 37 => \true, 38 => \true, 39 => \true, 40 => \true, 41 => \true, 42 => \true, 43 => \true, 44 => \true, 47 => \true, 58 => \true, 59 => \true, 60 => \true, 61 => \true, 62 => \true, 63 => \true, 64 => \true, 91 => \true, 92 => \true, 93 => \true, 94 => \true, 95 => \true, 96 => \true, 123 => \true, 124 => \true, 125 => \true, 126 => \true, 127 => \true, 8800 => \true, 8814 => \true, 8815 => \true);
|
||||
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Vendor;
|
||||
|
||||
return array(173 => \true, 847 => \true, 6155 => \true, 6156 => \true, 6157 => \true, 8203 => \true, 8288 => \true, 8292 => \true, 65024 => \true, 65025 => \true, 65026 => \true, 65027 => \true, 65028 => \true, 65029 => \true, 65030 => \true, 65031 => \true, 65032 => \true, 65033 => \true, 65034 => \true, 65035 => \true, 65036 => \true, 65037 => \true, 65038 => \true, 65039 => \true, 65279 => \true, 113824 => \true, 113825 => \true, 113826 => \true, 113827 => \true, 917760 => \true, 917761 => \true, 917762 => \true, 917763 => \true, 917764 => \true, 917765 => \true, 917766 => \true, 917767 => \true, 917768 => \true, 917769 => \true, 917770 => \true, 917771 => \true, 917772 => \true, 917773 => \true, 917774 => \true, 917775 => \true, 917776 => \true, 917777 => \true, 917778 => \true, 917779 => \true, 917780 => \true, 917781 => \true, 917782 => \true, 917783 => \true, 917784 => \true, 917785 => \true, 917786 => \true, 917787 => \true, 917788 => \true, 917789 => \true, 917790 => \true, 917791 => \true, 917792 => \true, 917793 => \true, 917794 => \true, 917795 => \true, 917796 => \true, 917797 => \true, 917798 => \true, 917799 => \true, 917800 => \true, 917801 => \true, 917802 => \true, 917803 => \true, 917804 => \true, 917805 => \true, 917806 => \true, 917807 => \true, 917808 => \true, 917809 => \true, 917810 => \true, 917811 => \true, 917812 => \true, 917813 => \true, 917814 => \true, 917815 => \true, 917816 => \true, 917817 => \true, 917818 => \true, 917819 => \true, 917820 => \true, 917821 => \true, 917822 => \true, 917823 => \true, 917824 => \true, 917825 => \true, 917826 => \true, 917827 => \true, 917828 => \true, 917829 => \true, 917830 => \true, 917831 => \true, 917832 => \true, 917833 => \true, 917834 => \true, 917835 => \true, 917836 => \true, 917837 => \true, 917838 => \true, 917839 => \true, 917840 => \true, 917841 => \true, 917842 => \true, 917843 => \true, 917844 => \true, 917845 => \true, 917846 => \true, 917847 => \true, 917848 => \true, 917849 => \true, 917850 => \true, 917851 => \true, 917852 => \true, 917853 => \true, 917854 => \true, 917855 => \true, 917856 => \true, 917857 => \true, 917858 => \true, 917859 => \true, 917860 => \true, 917861 => \true, 917862 => \true, 917863 => \true, 917864 => \true, 917865 => \true, 917866 => \true, 917867 => \true, 917868 => \true, 917869 => \true, 917870 => \true, 917871 => \true, 917872 => \true, 917873 => \true, 917874 => \true, 917875 => \true, 917876 => \true, 917877 => \true, 917878 => \true, 917879 => \true, 917880 => \true, 917881 => \true, 917882 => \true, 917883 => \true, 917884 => \true, 917885 => \true, 917886 => \true, 917887 => \true, 917888 => \true, 917889 => \true, 917890 => \true, 917891 => \true, 917892 => \true, 917893 => \true, 917894 => \true, 917895 => \true, 917896 => \true, 917897 => \true, 917898 => \true, 917899 => \true, 917900 => \true, 917901 => \true, 917902 => \true, 917903 => \true, 917904 => \true, 917905 => \true, 917906 => \true, 917907 => \true, 917908 => \true, 917909 => \true, 917910 => \true, 917911 => \true, 917912 => \true, 917913 => \true, 917914 => \true, 917915 => \true, 917916 => \true, 917917 => \true, 917918 => \true, 917919 => \true, 917920 => \true, 917921 => \true, 917922 => \true, 917923 => \true, 917924 => \true, 917925 => \true, 917926 => \true, 917927 => \true, 917928 => \true, 917929 => \true, 917930 => \true, 917931 => \true, 917932 => \true, 917933 => \true, 917934 => \true, 917935 => \true, 917936 => \true, 917937 => \true, 917938 => \true, 917939 => \true, 917940 => \true, 917941 => \true, 917942 => \true, 917943 => \true, 917944 => \true, 917945 => \true, 917946 => \true, 917947 => \true, 917948 => \true, 917949 => \true, 917950 => \true, 917951 => \true, 917952 => \true, 917953 => \true, 917954 => \true, 917955 => \true, 917956 => \true, 917957 => \true, 917958 => \true, 917959 => \true, 917960 => \true, 917961 => \true, 917962 => \true, 917963 => \true, 917964 => \true, 917965 => \true, 917966 => \true, 917967 => \true, 917968 => \true, 917969 => \true, 917970 => \true, 917971 => \true, 917972 => \true, 917973 => \true, 917974 => \true, 917975 => \true, 917976 => \true, 917977 => \true, 917978 => \true, 917979 => \true, 917980 => \true, 917981 => \true, 917982 => \true, 917983 => \true, 917984 => \true, 917985 => \true, 917986 => \true, 917987 => \true, 917988 => \true, 917989 => \true, 917990 => \true, 917991 => \true, 917992 => \true, 917993 => \true, 917994 => \true, 917995 => \true, 917996 => \true, 917997 => \true, 917998 => \true, 917999 => \true);
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Vendor;
|
||||
|
||||
return array(2381 => 9, 2509 => 9, 2637 => 9, 2765 => 9, 2893 => 9, 3021 => 9, 3149 => 9, 3277 => 9, 3387 => 9, 3388 => 9, 3405 => 9, 3530 => 9, 3642 => 9, 3770 => 9, 3972 => 9, 4153 => 9, 4154 => 9, 5908 => 9, 5940 => 9, 6098 => 9, 6752 => 9, 6980 => 9, 7082 => 9, 7083 => 9, 7154 => 9, 7155 => 9, 11647 => 9, 43014 => 9, 43052 => 9, 43204 => 9, 43347 => 9, 43456 => 9, 43766 => 9, 44013 => 9, 68159 => 9, 69702 => 9, 69759 => 9, 69817 => 9, 69939 => 9, 69940 => 9, 70080 => 9, 70197 => 9, 70378 => 9, 70477 => 9, 70722 => 9, 70850 => 9, 71103 => 9, 71231 => 9, 71350 => 9, 71467 => 9, 71737 => 9, 71997 => 9, 71998 => 9, 72160 => 9, 72244 => 9, 72263 => 9, 72345 => 9, 72767 => 9, 73028 => 9, 73029 => 9, 73111 => 9);
|
||||
@@ -15,6 +15,10 @@ if (extension_loaded('intl')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (\PHP_VERSION_ID >= 80000) {
|
||||
return require __DIR__.'/bootstrap80.php';
|
||||
}
|
||||
|
||||
if (!defined('U_IDNA_PROHIBITED_ERROR')) {
|
||||
define('U_IDNA_PROHIBITED_ERROR', 66560);
|
||||
}
|
||||
@@ -124,18 +128,18 @@ if (!defined('IDNA_ERROR_CONTEXTJ')) {
|
||||
define('IDNA_ERROR_CONTEXTJ', 4096);
|
||||
}
|
||||
|
||||
if (PHP_VERSION_ID < 70400) {
|
||||
if (\PHP_VERSION_ID < 70400) {
|
||||
if (!function_exists('idn_to_ascii')) {
|
||||
function idn_to_ascii($domain, $options = IDNA_DEFAULT, $variant = INTL_IDNA_VARIANT_2003, &$idna_info = array()) { return p\Idn::idn_to_ascii($domain, $options, $variant, $idna_info); }
|
||||
function idn_to_ascii($domain, $flags = 0, $variant = \INTL_IDNA_VARIANT_2003, &$idna_info = null) { return p\Idn::idn_to_ascii($domain, $flags, $variant, $idna_info); }
|
||||
}
|
||||
if (!function_exists('idn_to_utf8')) {
|
||||
function idn_to_utf8($domain, $options = IDNA_DEFAULT, $variant = INTL_IDNA_VARIANT_2003, &$idna_info = array()) { return p\Idn::idn_to_utf8($domain, $options, $variant, $idna_info); }
|
||||
function idn_to_utf8($domain, $flags = 0, $variant = \INTL_IDNA_VARIANT_2003, &$idna_info = null) { return p\Idn::idn_to_utf8($domain, $flags, $variant, $idna_info); }
|
||||
}
|
||||
} else {
|
||||
if (!function_exists('idn_to_ascii')) {
|
||||
function idn_to_ascii($domain, $options = IDNA_DEFAULT, $variant = INTL_IDNA_VARIANT_UTS46, &$idna_info = array()) { return p\Idn::idn_to_ascii($domain, $options, $variant, $idna_info); }
|
||||
function idn_to_ascii($domain, $flags = 0, $variant = \INTL_IDNA_VARIANT_UTS46, &$idna_info = null) { return p\Idn::idn_to_ascii($domain, $flags, $variant, $idna_info); }
|
||||
}
|
||||
if (!function_exists('idn_to_utf8')) {
|
||||
function idn_to_utf8($domain, $options = IDNA_DEFAULT, $variant = INTL_IDNA_VARIANT_UTS46, &$idna_info = array()) { return p\Idn::idn_to_utf8($domain, $options, $variant, $idna_info); }
|
||||
function idn_to_utf8($domain, $flags = 0, $variant = \INTL_IDNA_VARIANT_UTS46, &$idna_info = null) { return p\Idn::idn_to_utf8($domain, $flags, $variant, $idna_info); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Vendor;
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use WPMailSMTP\Vendor\Symfony\Polyfill\Intl\Idn as p;
|
||||
if (!\defined('U_IDNA_PROHIBITED_ERROR')) {
|
||||
\define('U_IDNA_PROHIBITED_ERROR', 66560);
|
||||
}
|
||||
if (!\defined('U_IDNA_ERROR_START')) {
|
||||
\define('U_IDNA_ERROR_START', 66560);
|
||||
}
|
||||
if (!\defined('U_IDNA_UNASSIGNED_ERROR')) {
|
||||
\define('U_IDNA_UNASSIGNED_ERROR', 66561);
|
||||
}
|
||||
if (!\defined('U_IDNA_CHECK_BIDI_ERROR')) {
|
||||
\define('U_IDNA_CHECK_BIDI_ERROR', 66562);
|
||||
}
|
||||
if (!\defined('U_IDNA_STD3_ASCII_RULES_ERROR')) {
|
||||
\define('U_IDNA_STD3_ASCII_RULES_ERROR', 66563);
|
||||
}
|
||||
if (!\defined('U_IDNA_ACE_PREFIX_ERROR')) {
|
||||
\define('U_IDNA_ACE_PREFIX_ERROR', 66564);
|
||||
}
|
||||
if (!\defined('U_IDNA_VERIFICATION_ERROR')) {
|
||||
\define('U_IDNA_VERIFICATION_ERROR', 66565);
|
||||
}
|
||||
if (!\defined('U_IDNA_LABEL_TOO_LONG_ERROR')) {
|
||||
\define('U_IDNA_LABEL_TOO_LONG_ERROR', 66566);
|
||||
}
|
||||
if (!\defined('U_IDNA_ZERO_LENGTH_LABEL_ERROR')) {
|
||||
\define('U_IDNA_ZERO_LENGTH_LABEL_ERROR', 66567);
|
||||
}
|
||||
if (!\defined('U_IDNA_DOMAIN_NAME_TOO_LONG_ERROR')) {
|
||||
\define('U_IDNA_DOMAIN_NAME_TOO_LONG_ERROR', 66568);
|
||||
}
|
||||
if (!\defined('U_IDNA_ERROR_LIMIT')) {
|
||||
\define('U_IDNA_ERROR_LIMIT', 66569);
|
||||
}
|
||||
if (!\defined('U_STRINGPREP_PROHIBITED_ERROR')) {
|
||||
\define('U_STRINGPREP_PROHIBITED_ERROR', 66560);
|
||||
}
|
||||
if (!\defined('U_STRINGPREP_UNASSIGNED_ERROR')) {
|
||||
\define('U_STRINGPREP_UNASSIGNED_ERROR', 66561);
|
||||
}
|
||||
if (!\defined('U_STRINGPREP_CHECK_BIDI_ERROR')) {
|
||||
\define('U_STRINGPREP_CHECK_BIDI_ERROR', 66562);
|
||||
}
|
||||
if (!\defined('IDNA_DEFAULT')) {
|
||||
\define('IDNA_DEFAULT', 0);
|
||||
}
|
||||
if (!\defined('IDNA_ALLOW_UNASSIGNED')) {
|
||||
\define('IDNA_ALLOW_UNASSIGNED', 1);
|
||||
}
|
||||
if (!\defined('IDNA_USE_STD3_RULES')) {
|
||||
\define('IDNA_USE_STD3_RULES', 2);
|
||||
}
|
||||
if (!\defined('IDNA_CHECK_BIDI')) {
|
||||
\define('IDNA_CHECK_BIDI', 4);
|
||||
}
|
||||
if (!\defined('IDNA_CHECK_CONTEXTJ')) {
|
||||
\define('IDNA_CHECK_CONTEXTJ', 8);
|
||||
}
|
||||
if (!\defined('IDNA_NONTRANSITIONAL_TO_ASCII')) {
|
||||
\define('IDNA_NONTRANSITIONAL_TO_ASCII', 16);
|
||||
}
|
||||
if (!\defined('IDNA_NONTRANSITIONAL_TO_UNICODE')) {
|
||||
\define('IDNA_NONTRANSITIONAL_TO_UNICODE', 32);
|
||||
}
|
||||
if (!\defined('INTL_IDNA_VARIANT_UTS46')) {
|
||||
\define('INTL_IDNA_VARIANT_UTS46', 1);
|
||||
}
|
||||
if (!\defined('IDNA_ERROR_EMPTY_LABEL')) {
|
||||
\define('IDNA_ERROR_EMPTY_LABEL', 1);
|
||||
}
|
||||
if (!\defined('IDNA_ERROR_LABEL_TOO_LONG')) {
|
||||
\define('IDNA_ERROR_LABEL_TOO_LONG', 2);
|
||||
}
|
||||
if (!\defined('IDNA_ERROR_DOMAIN_NAME_TOO_LONG')) {
|
||||
\define('IDNA_ERROR_DOMAIN_NAME_TOO_LONG', 4);
|
||||
}
|
||||
if (!\defined('IDNA_ERROR_LEADING_HYPHEN')) {
|
||||
\define('IDNA_ERROR_LEADING_HYPHEN', 8);
|
||||
}
|
||||
if (!\defined('IDNA_ERROR_TRAILING_HYPHEN')) {
|
||||
\define('IDNA_ERROR_TRAILING_HYPHEN', 16);
|
||||
}
|
||||
if (!\defined('IDNA_ERROR_HYPHEN_3_4')) {
|
||||
\define('IDNA_ERROR_HYPHEN_3_4', 32);
|
||||
}
|
||||
if (!\defined('IDNA_ERROR_LEADING_COMBINING_MARK')) {
|
||||
\define('IDNA_ERROR_LEADING_COMBINING_MARK', 64);
|
||||
}
|
||||
if (!\defined('IDNA_ERROR_DISALLOWED')) {
|
||||
\define('IDNA_ERROR_DISALLOWED', 128);
|
||||
}
|
||||
if (!\defined('IDNA_ERROR_PUNYCODE')) {
|
||||
\define('IDNA_ERROR_PUNYCODE', 256);
|
||||
}
|
||||
if (!\defined('IDNA_ERROR_LABEL_HAS_DOT')) {
|
||||
\define('IDNA_ERROR_LABEL_HAS_DOT', 512);
|
||||
}
|
||||
if (!\defined('IDNA_ERROR_INVALID_ACE_LABEL')) {
|
||||
\define('IDNA_ERROR_INVALID_ACE_LABEL', 1024);
|
||||
}
|
||||
if (!\defined('IDNA_ERROR_BIDI')) {
|
||||
\define('IDNA_ERROR_BIDI', 2048);
|
||||
}
|
||||
if (!\defined('IDNA_ERROR_CONTEXTJ')) {
|
||||
\define('IDNA_ERROR_CONTEXTJ', 4096);
|
||||
}
|
||||
if (!\function_exists('idn_to_ascii')) {
|
||||
function idn_to_ascii(?string $domain, ?int $flags = \IDNA_DEFAULT, ?int $variant = \INTL_IDNA_VARIANT_UTS46, &$idna_info = null) : string|false
|
||||
{
|
||||
return \WPMailSMTP\Vendor\Symfony\Polyfill\Intl\Idn\Idn::idn_to_ascii((string) $domain, (int) $flags, (int) $variant, $idna_info);
|
||||
}
|
||||
}
|
||||
if (!\function_exists('idn_to_utf8')) {
|
||||
function idn_to_utf8(?string $domain, ?int $flags = \IDNA_DEFAULT, ?int $variant = \INTL_IDNA_VARIANT_UTS46, &$idna_info = null) : string|false
|
||||
{
|
||||
return \WPMailSMTP\Vendor\Symfony\Polyfill\Intl\Idn\Idn::idn_to_utf8((string) $domain, (int) $flags, (int) $variant, $idna_info);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2015-2019 Fabien Potencier
|
||||
Copyright (c) 2015-present Fabien Potencier
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -66,14 +66,14 @@ namespace WPMailSMTP\Vendor\Symfony\Polyfill\Mbstring;
|
||||
*/
|
||||
final class Mbstring
|
||||
{
|
||||
const MB_CASE_FOLD = \PHP_INT_MAX;
|
||||
private static $encodingList = array('ASCII', 'UTF-8');
|
||||
public const MB_CASE_FOLD = \PHP_INT_MAX;
|
||||
private const SIMPLE_CASE_FOLD = [['µ', 'ſ', "ͅ", 'ς', "ϐ", "ϑ", "ϕ", "ϖ", "ϰ", "ϱ", "ϵ", "ẛ", "ι"], ['μ', 's', 'ι', 'σ', 'β', 'θ', 'φ', 'π', 'κ', 'ρ', 'ε', "ṡ", 'ι']];
|
||||
private static $encodingList = ['ASCII', 'UTF-8'];
|
||||
private static $language = 'neutral';
|
||||
private static $internalEncoding = 'UTF-8';
|
||||
private static $caseFold = array(array('µ', 'ſ', "ͅ", 'ς', "ϐ", "ϑ", "ϕ", "ϖ", "ϰ", "ϱ", "ϵ", "ẛ", "ι"), array('μ', 's', 'ι', 'σ', 'β', 'θ', 'φ', 'π', 'κ', 'ρ', 'ε', "ṡ", 'ι'));
|
||||
public static function mb_convert_encoding($s, $toEncoding, $fromEncoding = null)
|
||||
{
|
||||
if (\is_array($fromEncoding) || \false !== \strpos($fromEncoding, ',')) {
|
||||
if (\is_array($fromEncoding) || null !== $fromEncoding && \false !== \strpos($fromEncoding, ',')) {
|
||||
$fromEncoding = self::mb_detect_encoding($s, $fromEncoding);
|
||||
} else {
|
||||
$fromEncoding = self::getEncoding($fromEncoding);
|
||||
@@ -93,7 +93,7 @@ final class Mbstring
|
||||
if ('UTF-8' !== $fromEncoding) {
|
||||
$s = \iconv($fromEncoding, 'UTF-8//IGNORE', $s);
|
||||
}
|
||||
return \preg_replace_callback('/[\\x80-\\xFF]+/', array(__CLASS__, 'html_encoding_callback'), $s);
|
||||
return \preg_replace_callback('/[\\x80-\\xFF]+/', [__CLASS__, 'html_encoding_callback'], $s);
|
||||
}
|
||||
if ('HTML-ENTITIES' === $fromEncoding) {
|
||||
$s = \html_entity_decode($s, \ENT_COMPAT, 'UTF-8');
|
||||
@@ -101,12 +101,11 @@ final class Mbstring
|
||||
}
|
||||
return \iconv($fromEncoding, $toEncoding . '//IGNORE', $s);
|
||||
}
|
||||
public static function mb_convert_variables($toEncoding, $fromEncoding, &$a = null, &$b = null, &$c = null, &$d = null, &$e = null, &$f = null)
|
||||
public static function mb_convert_variables($toEncoding, $fromEncoding, &...$vars)
|
||||
{
|
||||
$vars = array(&$a, &$b, &$c, &$d, &$e, &$f);
|
||||
$ok = \true;
|
||||
\array_walk_recursive($vars, function (&$v) use(&$ok, $toEncoding, $fromEncoding) {
|
||||
if (\false === ($v = \WPMailSMTP\Vendor\Symfony\Polyfill\Mbstring\Mbstring::mb_convert_encoding($v, $toEncoding, $fromEncoding))) {
|
||||
if (\false === ($v = self::mb_convert_encoding($v, $toEncoding, $fromEncoding))) {
|
||||
$ok = \false;
|
||||
}
|
||||
});
|
||||
@@ -126,7 +125,7 @@ final class Mbstring
|
||||
\trigger_error('mb_decode_numericentity() expects parameter 1 to be string, ' . \gettype($s) . ' given', \E_USER_WARNING);
|
||||
return null;
|
||||
}
|
||||
if (!\is_array($convmap) || !$convmap) {
|
||||
if (!\is_array($convmap) || 80000 > \PHP_VERSION_ID && !$convmap) {
|
||||
return \false;
|
||||
}
|
||||
if (null !== $encoding && !\is_scalar($encoding)) {
|
||||
@@ -157,7 +156,7 @@ final class Mbstring
|
||||
$c = isset($m[2]) ? (int) \hexdec($m[2]) : $m[1];
|
||||
for ($i = 0; $i < $cnt; $i += 4) {
|
||||
if ($c >= $convmap[$i] && $c <= $convmap[$i + 1]) {
|
||||
return \WPMailSMTP\Vendor\Symfony\Polyfill\Mbstring\Mbstring::mb_chr($c - $convmap[$i + 2]);
|
||||
return self::mb_chr($c - $convmap[$i + 2]);
|
||||
}
|
||||
}
|
||||
return $m[0];
|
||||
@@ -173,7 +172,7 @@ final class Mbstring
|
||||
\trigger_error('mb_encode_numericentity() expects parameter 1 to be string, ' . \gettype($s) . ' given', \E_USER_WARNING);
|
||||
return null;
|
||||
}
|
||||
if (!\is_array($convmap) || !$convmap) {
|
||||
if (!\is_array($convmap) || 80000 > \PHP_VERSION_ID && !$convmap) {
|
||||
return \false;
|
||||
}
|
||||
if (null !== $encoding && !\is_scalar($encoding)) {
|
||||
@@ -198,7 +197,7 @@ final class Mbstring
|
||||
} else {
|
||||
$s = \iconv($encoding, 'UTF-8//IGNORE', $s);
|
||||
}
|
||||
static $ulenMask = array("<EFBFBD>" => 2, "<EFBFBD>" => 2, "<EFBFBD>" => 3, "<EFBFBD>" => 4);
|
||||
static $ulenMask = ["<EFBFBD>" => 2, "<EFBFBD>" => 2, "<EFBFBD>" => 3, "<EFBFBD>" => 4];
|
||||
$cnt = \floor(\count($convmap) / 4) * 4;
|
||||
$i = 0;
|
||||
$len = \strlen($s);
|
||||
@@ -242,7 +241,7 @@ final class Mbstring
|
||||
if (null === $titleRegexp) {
|
||||
$titleRegexp = self::getData('titleCaseRegexp');
|
||||
}
|
||||
$s = \preg_replace_callback($titleRegexp, array(__CLASS__, 'title_case'), $s);
|
||||
$s = \preg_replace_callback($titleRegexp, [__CLASS__, 'title_case'], $s);
|
||||
} else {
|
||||
if (\MB_CASE_UPPER == $mode) {
|
||||
static $upper = null;
|
||||
@@ -252,7 +251,11 @@ final class Mbstring
|
||||
$map = $upper;
|
||||
} else {
|
||||
if (self::MB_CASE_FOLD === $mode) {
|
||||
$s = \str_replace(self::$caseFold[0], self::$caseFold[1], $s);
|
||||
static $caseFolding = null;
|
||||
if (null === $caseFolding) {
|
||||
$caseFolding = self::getData('caseFolding');
|
||||
}
|
||||
$s = \strtr($s, $caseFolding);
|
||||
}
|
||||
static $lower = null;
|
||||
if (null === $lower) {
|
||||
@@ -260,7 +263,7 @@ final class Mbstring
|
||||
}
|
||||
$map = $lower;
|
||||
}
|
||||
static $ulenMask = array("<EFBFBD>" => 2, "<EFBFBD>" => 2, "<EFBFBD>" => 3, "<EFBFBD>" => 4);
|
||||
static $ulenMask = ["<EFBFBD>" => 2, "<EFBFBD>" => 2, "<EFBFBD>" => 3, "<EFBFBD>" => 4];
|
||||
$i = 0;
|
||||
$len = \strlen($s);
|
||||
while ($i < $len) {
|
||||
@@ -293,48 +296,69 @@ final class Mbstring
|
||||
if (null === $encoding) {
|
||||
return self::$internalEncoding;
|
||||
}
|
||||
$encoding = self::getEncoding($encoding);
|
||||
if ('UTF-8' === $encoding || \false !== @\iconv($encoding, $encoding, ' ')) {
|
||||
self::$internalEncoding = $encoding;
|
||||
$normalizedEncoding = self::getEncoding($encoding);
|
||||
if ('UTF-8' === $normalizedEncoding || \false !== @\iconv($normalizedEncoding, $normalizedEncoding, ' ')) {
|
||||
self::$internalEncoding = $normalizedEncoding;
|
||||
return \true;
|
||||
}
|
||||
return \false;
|
||||
if (80000 > \PHP_VERSION_ID) {
|
||||
return \false;
|
||||
}
|
||||
throw new \ValueError(\sprintf('Argument #1 ($encoding) must be a valid encoding, "%s" given', $encoding));
|
||||
}
|
||||
public static function mb_language($lang = null)
|
||||
{
|
||||
if (null === $lang) {
|
||||
return self::$language;
|
||||
}
|
||||
switch ($lang = \strtolower($lang)) {
|
||||
switch ($normalizedLang = \strtolower($lang)) {
|
||||
case 'uni':
|
||||
case 'neutral':
|
||||
self::$language = $lang;
|
||||
self::$language = $normalizedLang;
|
||||
return \true;
|
||||
}
|
||||
return \false;
|
||||
if (80000 > \PHP_VERSION_ID) {
|
||||
return \false;
|
||||
}
|
||||
throw new \ValueError(\sprintf('Argument #1 ($language) must be a valid language, "%s" given', $lang));
|
||||
}
|
||||
public static function mb_list_encodings()
|
||||
{
|
||||
return array('UTF-8');
|
||||
return ['UTF-8'];
|
||||
}
|
||||
public static function mb_encoding_aliases($encoding)
|
||||
{
|
||||
switch (\strtoupper($encoding)) {
|
||||
case 'UTF8':
|
||||
case 'UTF-8':
|
||||
return array('utf8');
|
||||
return ['utf8'];
|
||||
}
|
||||
return \false;
|
||||
}
|
||||
public static function mb_check_encoding($var = null, $encoding = null)
|
||||
{
|
||||
if (\PHP_VERSION_ID < 70200 && \is_array($var)) {
|
||||
\trigger_error('mb_check_encoding() expects parameter 1 to be string, array given', \E_USER_WARNING);
|
||||
return null;
|
||||
}
|
||||
if (null === $encoding) {
|
||||
if (null === $var) {
|
||||
return \false;
|
||||
}
|
||||
$encoding = self::$internalEncoding;
|
||||
}
|
||||
return self::mb_detect_encoding($var, array($encoding)) || \false !== @\iconv($encoding, $encoding, $var);
|
||||
if (!\is_array($var)) {
|
||||
return self::mb_detect_encoding($var, [$encoding]) || \false !== @\iconv($encoding, $encoding, $var);
|
||||
}
|
||||
foreach ($var as $key => $value) {
|
||||
if (!self::mb_check_encoding($key, $encoding)) {
|
||||
return \false;
|
||||
}
|
||||
if (!self::mb_check_encoding($value, $encoding)) {
|
||||
return \false;
|
||||
}
|
||||
}
|
||||
return \true;
|
||||
}
|
||||
public static function mb_detect_encoding($str, $encodingList = null, $strict = \false)
|
||||
{
|
||||
@@ -407,8 +431,11 @@ final class Mbstring
|
||||
}
|
||||
$needle = (string) $needle;
|
||||
if ('' === $needle) {
|
||||
\trigger_error(__METHOD__ . ': Empty delimiter', \E_USER_WARNING);
|
||||
return \false;
|
||||
if (80000 > \PHP_VERSION_ID) {
|
||||
\trigger_error(__METHOD__ . ': Empty delimiter', \E_USER_WARNING);
|
||||
return \false;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return \iconv_strpos($haystack, $needle, $offset, $encoding);
|
||||
}
|
||||
@@ -430,7 +457,7 @@ final class Mbstring
|
||||
$haystack = self::mb_substr($haystack, $offset, 2147483647, $encoding);
|
||||
}
|
||||
}
|
||||
$pos = \iconv_strrpos($haystack, $needle, $encoding);
|
||||
$pos = '' !== $needle || 80000 > \PHP_VERSION_ID ? \iconv_strrpos($haystack, $needle, $encoding) : self::mb_strlen($haystack, $encoding);
|
||||
return \false !== $pos ? $offset + $pos : \false;
|
||||
}
|
||||
public static function mb_str_split($string, $split_length = 1, $encoding = null)
|
||||
@@ -440,8 +467,11 @@ final class Mbstring
|
||||
return null;
|
||||
}
|
||||
if (1 > ($split_length = (int) $split_length)) {
|
||||
\trigger_error('The length of each segment must be greater than zero', \E_USER_WARNING);
|
||||
return \false;
|
||||
if (80000 > \PHP_VERSION_ID) {
|
||||
\trigger_error('The length of each segment must be greater than zero', \E_USER_WARNING);
|
||||
return \false;
|
||||
}
|
||||
throw new \ValueError('Argument #2 ($length) must be greater than 0');
|
||||
}
|
||||
if (null === $encoding) {
|
||||
$encoding = \mb_internal_encoding();
|
||||
@@ -453,9 +483,9 @@ final class Mbstring
|
||||
$split_length -= 65535;
|
||||
}
|
||||
$rx .= '.{' . $split_length . '})/us';
|
||||
return \preg_split($rx, $string, null, \PREG_SPLIT_DELIM_CAPTURE | \PREG_SPLIT_NO_EMPTY);
|
||||
return \preg_split($rx, $string, -1, \PREG_SPLIT_DELIM_CAPTURE | \PREG_SPLIT_NO_EMPTY);
|
||||
}
|
||||
$result = array();
|
||||
$result = [];
|
||||
$length = \mb_strlen($string, $encoding);
|
||||
for ($i = 0; $i < $length; $i += $split_length) {
|
||||
$result[] = \mb_substr($string, $i, $split_length, $encoding);
|
||||
@@ -472,10 +502,19 @@ final class Mbstring
|
||||
}
|
||||
public static function mb_substitute_character($c = null)
|
||||
{
|
||||
if (null === $c) {
|
||||
return 'none';
|
||||
}
|
||||
if (0 === \strcasecmp($c, 'none')) {
|
||||
return \true;
|
||||
}
|
||||
return null !== $c ? \false : 'none';
|
||||
if (80000 > \PHP_VERSION_ID) {
|
||||
return \false;
|
||||
}
|
||||
if (\is_int($c) || 'long' === $c || 'entity' === $c) {
|
||||
return \false;
|
||||
}
|
||||
throw new \ValueError('Argument #1 ($substitute_character) must be "none", "long", "entity" or a valid codepoint');
|
||||
}
|
||||
public static function mb_substr($s, $start, $length = null, $encoding = null)
|
||||
{
|
||||
@@ -501,8 +540,7 @@ final class Mbstring
|
||||
}
|
||||
public static function mb_stripos($haystack, $needle, $offset = 0, $encoding = null)
|
||||
{
|
||||
$haystack = self::mb_convert_case($haystack, self::MB_CASE_FOLD, $encoding);
|
||||
$needle = self::mb_convert_case($needle, self::MB_CASE_FOLD, $encoding);
|
||||
[$haystack, $needle] = \str_replace(self::SIMPLE_CASE_FOLD[0], self::SIMPLE_CASE_FOLD[1], [self::mb_convert_case($haystack, \MB_CASE_LOWER, $encoding), self::mb_convert_case($needle, \MB_CASE_LOWER, $encoding)]);
|
||||
return self::mb_strpos($haystack, $needle, $offset, $encoding);
|
||||
}
|
||||
public static function mb_stristr($haystack, $needle, $part = \false, $encoding = null)
|
||||
@@ -529,8 +567,10 @@ final class Mbstring
|
||||
}
|
||||
public static function mb_strripos($haystack, $needle, $offset = 0, $encoding = null)
|
||||
{
|
||||
$haystack = self::mb_convert_case($haystack, self::MB_CASE_FOLD, $encoding);
|
||||
$needle = self::mb_convert_case($needle, self::MB_CASE_FOLD, $encoding);
|
||||
$haystack = self::mb_convert_case($haystack, \MB_CASE_LOWER, $encoding);
|
||||
$needle = self::mb_convert_case($needle, \MB_CASE_LOWER, $encoding);
|
||||
$haystack = \str_replace(self::SIMPLE_CASE_FOLD[0], self::SIMPLE_CASE_FOLD[1], $haystack);
|
||||
$needle = \str_replace(self::SIMPLE_CASE_FOLD[0], self::SIMPLE_CASE_FOLD[1], $needle);
|
||||
return self::mb_strrpos($haystack, $needle, $offset, $encoding);
|
||||
}
|
||||
public static function mb_strstr($haystack, $needle, $part = \false, $encoding = null)
|
||||
@@ -546,7 +586,7 @@ final class Mbstring
|
||||
}
|
||||
public static function mb_get_info($type = 'all')
|
||||
{
|
||||
$info = array('internal_encoding' => self::$internalEncoding, 'http_output' => 'pass', 'http_output_conv_mimetypes' => '^(text/|application/xhtml\\+xml)', 'func_overload' => 0, 'func_overload_list' => 'no overload', 'mail_charset' => 'UTF-8', 'mail_header_encoding' => 'BASE64', 'mail_body_encoding' => 'BASE64', 'illegal_chars' => 0, 'encoding_translation' => 'Off', 'language' => self::$language, 'detect_order' => self::$encodingList, 'substitute_character' => 'none', 'strict_detection' => 'Off');
|
||||
$info = ['internal_encoding' => self::$internalEncoding, 'http_output' => 'pass', 'http_output_conv_mimetypes' => '^(text/|application/xhtml\\+xml)', 'func_overload' => 0, 'func_overload_list' => 'no overload', 'mail_charset' => 'UTF-8', 'mail_header_encoding' => 'BASE64', 'mail_body_encoding' => 'BASE64', 'illegal_chars' => 0, 'encoding_translation' => 'Off', 'language' => self::$language, 'detect_order' => self::$encodingList, 'substitute_character' => 'none', 'strict_detection' => 'Off'];
|
||||
if ('all' === $type) {
|
||||
return $info;
|
||||
}
|
||||
@@ -616,6 +656,41 @@ final class Mbstring
|
||||
}
|
||||
return $code;
|
||||
}
|
||||
public static function mb_str_pad(string $string, int $length, string $pad_string = ' ', int $pad_type = \STR_PAD_RIGHT, string $encoding = null) : string
|
||||
{
|
||||
if (!\in_array($pad_type, [\STR_PAD_RIGHT, \STR_PAD_LEFT, \STR_PAD_BOTH], \true)) {
|
||||
throw new \ValueError('mb_str_pad(): Argument #4 ($pad_type) must be STR_PAD_LEFT, STR_PAD_RIGHT, or STR_PAD_BOTH');
|
||||
}
|
||||
if (null === $encoding) {
|
||||
$encoding = self::mb_internal_encoding();
|
||||
}
|
||||
try {
|
||||
$validEncoding = @self::mb_check_encoding('', $encoding);
|
||||
} catch (\ValueError $e) {
|
||||
throw new \ValueError(\sprintf('mb_str_pad(): Argument #5 ($encoding) must be a valid encoding, "%s" given', $encoding));
|
||||
}
|
||||
// BC for PHP 7.3 and lower
|
||||
if (!$validEncoding) {
|
||||
throw new \ValueError(\sprintf('mb_str_pad(): Argument #5 ($encoding) must be a valid encoding, "%s" given', $encoding));
|
||||
}
|
||||
if (self::mb_strlen($pad_string, $encoding) <= 0) {
|
||||
throw new \ValueError('mb_str_pad(): Argument #3 ($pad_string) must be a non-empty string');
|
||||
}
|
||||
$paddingRequired = $length - self::mb_strlen($string, $encoding);
|
||||
if ($paddingRequired < 1) {
|
||||
return $string;
|
||||
}
|
||||
switch ($pad_type) {
|
||||
case \STR_PAD_LEFT:
|
||||
return self::mb_substr(\str_repeat($pad_string, $paddingRequired), 0, $paddingRequired, $encoding) . $string;
|
||||
case \STR_PAD_RIGHT:
|
||||
return $string . self::mb_substr(\str_repeat($pad_string, $paddingRequired), 0, $paddingRequired, $encoding);
|
||||
default:
|
||||
$leftPaddingLength = \floor($paddingRequired / 2);
|
||||
$rightPaddingLength = $paddingRequired - $leftPaddingLength;
|
||||
return self::mb_substr(\str_repeat($pad_string, $leftPaddingLength), 0, $leftPaddingLength, $encoding) . $string . self::mb_substr(\str_repeat($pad_string, $rightPaddingLength), 0, $rightPaddingLength, $encoding);
|
||||
}
|
||||
}
|
||||
private static function getSubpart($pos, $part, $haystack, $encoding)
|
||||
{
|
||||
if (\false === $pos) {
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use WPMailSMTP\Vendor\Symfony\Polyfill\Mbstring as p;
|
||||
|
||||
if (!function_exists('mb_convert_variables')) {
|
||||
/**
|
||||
* Convert character code in variable(s)
|
||||
*/
|
||||
function mb_convert_variables($to_encoding, $from_encoding, &$var, &...$vars)
|
||||
{
|
||||
$vars = [&$var, ...$vars];
|
||||
|
||||
$ok = true;
|
||||
array_walk_recursive($vars, function (&$v) use (&$ok, $to_encoding, $from_encoding) {
|
||||
if (false === $v = p\Mbstring::mb_convert_encoding($v, $to_encoding, $from_encoding)) {
|
||||
$ok = false;
|
||||
}
|
||||
});
|
||||
|
||||
return $ok ? $from_encoding : false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Vendor;
|
||||
|
||||
return ['İ' => 'i̇', 'µ' => 'μ', 'ſ' => 's', 'ͅ' => 'ι', 'ς' => 'σ', 'ϐ' => 'β', 'ϑ' => 'θ', 'ϕ' => 'φ', 'ϖ' => 'π', 'ϰ' => 'κ', 'ϱ' => 'ρ', 'ϵ' => 'ε', 'ẛ' => 'ṡ', 'ι' => 'ι', 'ß' => 'ss', 'ʼn' => 'ʼn', 'ǰ' => 'ǰ', 'ΐ' => 'ΐ', 'ΰ' => 'ΰ', 'և' => 'եւ', 'ẖ' => 'ẖ', 'ẗ' => 'ẗ', 'ẘ' => 'ẘ', 'ẙ' => 'ẙ', 'ẚ' => 'aʾ', 'ẞ' => 'ss', 'ὐ' => 'ὐ', 'ὒ' => 'ὒ', 'ὔ' => 'ὔ', 'ὖ' => 'ὖ', 'ᾀ' => 'ἀι', 'ᾁ' => 'ἁι', 'ᾂ' => 'ἂι', 'ᾃ' => 'ἃι', 'ᾄ' => 'ἄι', 'ᾅ' => 'ἅι', 'ᾆ' => 'ἆι', 'ᾇ' => 'ἇι', 'ᾈ' => 'ἀι', 'ᾉ' => 'ἁι', 'ᾊ' => 'ἂι', 'ᾋ' => 'ἃι', 'ᾌ' => 'ἄι', 'ᾍ' => 'ἅι', 'ᾎ' => 'ἆι', 'ᾏ' => 'ἇι', 'ᾐ' => 'ἠι', 'ᾑ' => 'ἡι', 'ᾒ' => 'ἢι', 'ᾓ' => 'ἣι', 'ᾔ' => 'ἤι', 'ᾕ' => 'ἥι', 'ᾖ' => 'ἦι', 'ᾗ' => 'ἧι', 'ᾘ' => 'ἠι', 'ᾙ' => 'ἡι', 'ᾚ' => 'ἢι', 'ᾛ' => 'ἣι', 'ᾜ' => 'ἤι', 'ᾝ' => 'ἥι', 'ᾞ' => 'ἦι', 'ᾟ' => 'ἧι', 'ᾠ' => 'ὠι', 'ᾡ' => 'ὡι', 'ᾢ' => 'ὢι', 'ᾣ' => 'ὣι', 'ᾤ' => 'ὤι', 'ᾥ' => 'ὥι', 'ᾦ' => 'ὦι', 'ᾧ' => 'ὧι', 'ᾨ' => 'ὠι', 'ᾩ' => 'ὡι', 'ᾪ' => 'ὢι', 'ᾫ' => 'ὣι', 'ᾬ' => 'ὤι', 'ᾭ' => 'ὥι', 'ᾮ' => 'ὦι', 'ᾯ' => 'ὧι', 'ᾲ' => 'ὰι', 'ᾳ' => 'αι', 'ᾴ' => 'άι', 'ᾶ' => 'ᾶ', 'ᾷ' => 'ᾶι', 'ᾼ' => 'αι', 'ῂ' => 'ὴι', 'ῃ' => 'ηι', 'ῄ' => 'ήι', 'ῆ' => 'ῆ', 'ῇ' => 'ῆι', 'ῌ' => 'ηι', 'ῒ' => 'ῒ', 'ῖ' => 'ῖ', 'ῗ' => 'ῗ', 'ῢ' => 'ῢ', 'ῤ' => 'ῤ', 'ῦ' => 'ῦ', 'ῧ' => 'ῧ', 'ῲ' => 'ὼι', 'ῳ' => 'ωι', 'ῴ' => 'ώι', 'ῶ' => 'ῶ', 'ῷ' => 'ῶι', 'ῼ' => 'ωι', 'ff' => 'ff', 'fi' => 'fi', 'fl' => 'fl', 'ffi' => 'ffi', 'ffl' => 'ffl', 'ſt' => 'st', 'st' => 'st', 'ﬓ' => 'մն', 'ﬔ' => 'մե', 'ﬕ' => 'մի', 'ﬖ' => 'վն', 'ﬗ' => 'մխ'];
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -11,6 +11,10 @@
|
||||
|
||||
use WPMailSMTP\Vendor\Symfony\Polyfill\Mbstring as p;
|
||||
|
||||
if (\PHP_VERSION_ID >= 80000) {
|
||||
return require __DIR__.'/bootstrap80.php';
|
||||
}
|
||||
|
||||
if (!function_exists('mb_convert_encoding')) {
|
||||
function mb_convert_encoding($string, $to_encoding, $from_encoding = null) { return p\Mbstring::mb_convert_encoding($string, $to_encoding, $from_encoding); }
|
||||
}
|
||||
@@ -18,7 +22,7 @@ if (!function_exists('mb_decode_mimeheader')) {
|
||||
function mb_decode_mimeheader($string) { return p\Mbstring::mb_decode_mimeheader($string); }
|
||||
}
|
||||
if (!function_exists('mb_encode_mimeheader')) {
|
||||
function mb_encode_mimeheader($string, $charset = null, $transfer_encoding = null, $newline = null, $indent = null) { return p\Mbstring::mb_encode_mimeheader($string, $charset, $transfer_encoding, $newline, $indent); }
|
||||
function mb_encode_mimeheader($string, $charset = null, $transfer_encoding = null, $newline = "\r\n", $indent = 0) { return p\Mbstring::mb_encode_mimeheader($string, $charset, $transfer_encoding, $newline, $indent); }
|
||||
}
|
||||
if (!function_exists('mb_decode_numericentity')) {
|
||||
function mb_decode_numericentity($string, $map, $encoding = null) { return p\Mbstring::mb_decode_numericentity($string, $map, $encoding); }
|
||||
@@ -51,7 +55,7 @@ if (!function_exists('mb_detect_order')) {
|
||||
function mb_detect_order($encoding = null) { return p\Mbstring::mb_detect_order($encoding); }
|
||||
}
|
||||
if (!function_exists('mb_parse_str')) {
|
||||
function mb_parse_str($string, &$result = array()) { parse_str($string, $result); }
|
||||
function mb_parse_str($string, &$result = []) { parse_str($string, $result); return (bool) $result; }
|
||||
}
|
||||
if (!function_exists('mb_strlen')) {
|
||||
function mb_strlen($string, $encoding = null) { return p\Mbstring::mb_strlen($string, $encoding); }
|
||||
@@ -108,13 +112,11 @@ if (!function_exists('mb_output_handler')) {
|
||||
function mb_output_handler($string, $status) { return p\Mbstring::mb_output_handler($string, $status); }
|
||||
}
|
||||
if (!function_exists('mb_http_input')) {
|
||||
function mb_http_input($type = '') { return p\Mbstring::mb_http_input($type); }
|
||||
function mb_http_input($type = null) { return p\Mbstring::mb_http_input($type); }
|
||||
}
|
||||
|
||||
if (PHP_VERSION_ID >= 80000) {
|
||||
require_once __DIR__.'/Resources/mb_convert_variables.php8';
|
||||
} elseif (!function_exists('mb_convert_variables')) {
|
||||
function mb_convert_variables($toEncoding, $fromEncoding, &$a = null, &$b = null, &$c = null, &$d = null, &$e = null, &$f = null) { return p\Mbstring::mb_convert_variables($toEncoding, $fromEncoding, $a, $b, $c, $d, $e, $f); }
|
||||
if (!function_exists('mb_convert_variables')) {
|
||||
function mb_convert_variables($to_encoding, $from_encoding, &...$vars) { return p\Mbstring::mb_convert_variables($to_encoding, $from_encoding, ...$vars); }
|
||||
}
|
||||
|
||||
if (!function_exists('mb_ord')) {
|
||||
@@ -130,6 +132,10 @@ if (!function_exists('mb_str_split')) {
|
||||
function mb_str_split($string, $length = 1, $encoding = null) { return p\Mbstring::mb_str_split($string, $length, $encoding); }
|
||||
}
|
||||
|
||||
if (!function_exists('mb_str_pad')) {
|
||||
function mb_str_pad(string $string, int $length, string $pad_string = ' ', int $pad_type = STR_PAD_RIGHT, ?string $encoding = null): string { return p\Mbstring::mb_str_pad($string, $length, $pad_string, $pad_type, $encoding); }
|
||||
}
|
||||
|
||||
if (extension_loaded('mbstring')) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,261 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Vendor;
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
use WPMailSMTP\Vendor\Symfony\Polyfill\Mbstring as p;
|
||||
if (!\function_exists('mb_convert_encoding')) {
|
||||
function mb_convert_encoding(array|string|null $string, ?string $to_encoding, array|string|null $from_encoding = null) : array|string|false
|
||||
{
|
||||
return \WPMailSMTP\Vendor\Symfony\Polyfill\Mbstring\Mbstring::mb_convert_encoding($string ?? '', (string) $to_encoding, $from_encoding);
|
||||
}
|
||||
}
|
||||
if (!\function_exists('mb_decode_mimeheader')) {
|
||||
function mb_decode_mimeheader(?string $string) : string
|
||||
{
|
||||
return \WPMailSMTP\Vendor\Symfony\Polyfill\Mbstring\Mbstring::mb_decode_mimeheader((string) $string);
|
||||
}
|
||||
}
|
||||
if (!\function_exists('mb_encode_mimeheader')) {
|
||||
function mb_encode_mimeheader(?string $string, ?string $charset = null, ?string $transfer_encoding = null, ?string $newline = "\r\n", ?int $indent = 0) : string
|
||||
{
|
||||
return \WPMailSMTP\Vendor\Symfony\Polyfill\Mbstring\Mbstring::mb_encode_mimeheader((string) $string, $charset, $transfer_encoding, (string) $newline, (int) $indent);
|
||||
}
|
||||
}
|
||||
if (!\function_exists('mb_decode_numericentity')) {
|
||||
function mb_decode_numericentity(?string $string, array $map, ?string $encoding = null) : string
|
||||
{
|
||||
return \WPMailSMTP\Vendor\Symfony\Polyfill\Mbstring\Mbstring::mb_decode_numericentity((string) $string, $map, $encoding);
|
||||
}
|
||||
}
|
||||
if (!\function_exists('mb_encode_numericentity')) {
|
||||
function mb_encode_numericentity(?string $string, array $map, ?string $encoding = null, ?bool $hex = \false) : string
|
||||
{
|
||||
return \WPMailSMTP\Vendor\Symfony\Polyfill\Mbstring\Mbstring::mb_encode_numericentity((string) $string, $map, $encoding, (bool) $hex);
|
||||
}
|
||||
}
|
||||
if (!\function_exists('mb_convert_case')) {
|
||||
function mb_convert_case(?string $string, ?int $mode, ?string $encoding = null) : string
|
||||
{
|
||||
return \WPMailSMTP\Vendor\Symfony\Polyfill\Mbstring\Mbstring::mb_convert_case((string) $string, (int) $mode, $encoding);
|
||||
}
|
||||
}
|
||||
if (!\function_exists('mb_internal_encoding')) {
|
||||
function mb_internal_encoding(?string $encoding = null) : string|bool
|
||||
{
|
||||
return \WPMailSMTP\Vendor\Symfony\Polyfill\Mbstring\Mbstring::mb_internal_encoding($encoding);
|
||||
}
|
||||
}
|
||||
if (!\function_exists('mb_language')) {
|
||||
function mb_language(?string $language = null) : string|bool
|
||||
{
|
||||
return \WPMailSMTP\Vendor\Symfony\Polyfill\Mbstring\Mbstring::mb_language($language);
|
||||
}
|
||||
}
|
||||
if (!\function_exists('mb_list_encodings')) {
|
||||
function mb_list_encodings() : array
|
||||
{
|
||||
return \WPMailSMTP\Vendor\Symfony\Polyfill\Mbstring\Mbstring::mb_list_encodings();
|
||||
}
|
||||
}
|
||||
if (!\function_exists('mb_encoding_aliases')) {
|
||||
function mb_encoding_aliases(?string $encoding) : array
|
||||
{
|
||||
return \WPMailSMTP\Vendor\Symfony\Polyfill\Mbstring\Mbstring::mb_encoding_aliases((string) $encoding);
|
||||
}
|
||||
}
|
||||
if (!\function_exists('mb_check_encoding')) {
|
||||
function mb_check_encoding(array|string|null $value = null, ?string $encoding = null) : bool
|
||||
{
|
||||
return \WPMailSMTP\Vendor\Symfony\Polyfill\Mbstring\Mbstring::mb_check_encoding($value, $encoding);
|
||||
}
|
||||
}
|
||||
if (!\function_exists('mb_detect_encoding')) {
|
||||
function mb_detect_encoding(?string $string, array|string|null $encodings = null, ?bool $strict = \false) : string|false
|
||||
{
|
||||
return \WPMailSMTP\Vendor\Symfony\Polyfill\Mbstring\Mbstring::mb_detect_encoding((string) $string, $encodings, (bool) $strict);
|
||||
}
|
||||
}
|
||||
if (!\function_exists('mb_detect_order')) {
|
||||
function mb_detect_order(array|string|null $encoding = null) : array|bool
|
||||
{
|
||||
return \WPMailSMTP\Vendor\Symfony\Polyfill\Mbstring\Mbstring::mb_detect_order($encoding);
|
||||
}
|
||||
}
|
||||
if (!\function_exists('mb_parse_str')) {
|
||||
function mb_parse_str(?string $string, &$result = []) : bool
|
||||
{
|
||||
\parse_str((string) $string, $result);
|
||||
return (bool) $result;
|
||||
}
|
||||
}
|
||||
if (!\function_exists('mb_strlen')) {
|
||||
function mb_strlen(?string $string, ?string $encoding = null) : int
|
||||
{
|
||||
return \WPMailSMTP\Vendor\Symfony\Polyfill\Mbstring\Mbstring::mb_strlen((string) $string, $encoding);
|
||||
}
|
||||
}
|
||||
if (!\function_exists('mb_strpos')) {
|
||||
function mb_strpos(?string $haystack, ?string $needle, ?int $offset = 0, ?string $encoding = null) : int|false
|
||||
{
|
||||
return \WPMailSMTP\Vendor\Symfony\Polyfill\Mbstring\Mbstring::mb_strpos((string) $haystack, (string) $needle, (int) $offset, $encoding);
|
||||
}
|
||||
}
|
||||
if (!\function_exists('mb_strtolower')) {
|
||||
function mb_strtolower(?string $string, ?string $encoding = null) : string
|
||||
{
|
||||
return \WPMailSMTP\Vendor\Symfony\Polyfill\Mbstring\Mbstring::mb_strtolower((string) $string, $encoding);
|
||||
}
|
||||
}
|
||||
if (!\function_exists('mb_strtoupper')) {
|
||||
function mb_strtoupper(?string $string, ?string $encoding = null) : string
|
||||
{
|
||||
return \WPMailSMTP\Vendor\Symfony\Polyfill\Mbstring\Mbstring::mb_strtoupper((string) $string, $encoding);
|
||||
}
|
||||
}
|
||||
if (!\function_exists('mb_substitute_character')) {
|
||||
function mb_substitute_character(string|int|null $substitute_character = null) : string|int|bool
|
||||
{
|
||||
return \WPMailSMTP\Vendor\Symfony\Polyfill\Mbstring\Mbstring::mb_substitute_character($substitute_character);
|
||||
}
|
||||
}
|
||||
if (!\function_exists('mb_substr')) {
|
||||
function mb_substr(?string $string, ?int $start, ?int $length = null, ?string $encoding = null) : string
|
||||
{
|
||||
return \WPMailSMTP\Vendor\Symfony\Polyfill\Mbstring\Mbstring::mb_substr((string) $string, (int) $start, $length, $encoding);
|
||||
}
|
||||
}
|
||||
if (!\function_exists('mb_stripos')) {
|
||||
function mb_stripos(?string $haystack, ?string $needle, ?int $offset = 0, ?string $encoding = null) : int|false
|
||||
{
|
||||
return \WPMailSMTP\Vendor\Symfony\Polyfill\Mbstring\Mbstring::mb_stripos((string) $haystack, (string) $needle, (int) $offset, $encoding);
|
||||
}
|
||||
}
|
||||
if (!\function_exists('mb_stristr')) {
|
||||
function mb_stristr(?string $haystack, ?string $needle, ?bool $before_needle = \false, ?string $encoding = null) : string|false
|
||||
{
|
||||
return \WPMailSMTP\Vendor\Symfony\Polyfill\Mbstring\Mbstring::mb_stristr((string) $haystack, (string) $needle, (bool) $before_needle, $encoding);
|
||||
}
|
||||
}
|
||||
if (!\function_exists('mb_strrchr')) {
|
||||
function mb_strrchr(?string $haystack, ?string $needle, ?bool $before_needle = \false, ?string $encoding = null) : string|false
|
||||
{
|
||||
return \WPMailSMTP\Vendor\Symfony\Polyfill\Mbstring\Mbstring::mb_strrchr((string) $haystack, (string) $needle, (bool) $before_needle, $encoding);
|
||||
}
|
||||
}
|
||||
if (!\function_exists('mb_strrichr')) {
|
||||
function mb_strrichr(?string $haystack, ?string $needle, ?bool $before_needle = \false, ?string $encoding = null) : string|false
|
||||
{
|
||||
return \WPMailSMTP\Vendor\Symfony\Polyfill\Mbstring\Mbstring::mb_strrichr((string) $haystack, (string) $needle, (bool) $before_needle, $encoding);
|
||||
}
|
||||
}
|
||||
if (!\function_exists('mb_strripos')) {
|
||||
function mb_strripos(?string $haystack, ?string $needle, ?int $offset = 0, ?string $encoding = null) : int|false
|
||||
{
|
||||
return \WPMailSMTP\Vendor\Symfony\Polyfill\Mbstring\Mbstring::mb_strripos((string) $haystack, (string) $needle, (int) $offset, $encoding);
|
||||
}
|
||||
}
|
||||
if (!\function_exists('mb_strrpos')) {
|
||||
function mb_strrpos(?string $haystack, ?string $needle, ?int $offset = 0, ?string $encoding = null) : int|false
|
||||
{
|
||||
return \WPMailSMTP\Vendor\Symfony\Polyfill\Mbstring\Mbstring::mb_strrpos((string) $haystack, (string) $needle, (int) $offset, $encoding);
|
||||
}
|
||||
}
|
||||
if (!\function_exists('mb_strstr')) {
|
||||
function mb_strstr(?string $haystack, ?string $needle, ?bool $before_needle = \false, ?string $encoding = null) : string|false
|
||||
{
|
||||
return \WPMailSMTP\Vendor\Symfony\Polyfill\Mbstring\Mbstring::mb_strstr((string) $haystack, (string) $needle, (bool) $before_needle, $encoding);
|
||||
}
|
||||
}
|
||||
if (!\function_exists('mb_get_info')) {
|
||||
function mb_get_info(?string $type = 'all') : array|string|int|false
|
||||
{
|
||||
return \WPMailSMTP\Vendor\Symfony\Polyfill\Mbstring\Mbstring::mb_get_info((string) $type);
|
||||
}
|
||||
}
|
||||
if (!\function_exists('mb_http_output')) {
|
||||
function mb_http_output(?string $encoding = null) : string|bool
|
||||
{
|
||||
return \WPMailSMTP\Vendor\Symfony\Polyfill\Mbstring\Mbstring::mb_http_output($encoding);
|
||||
}
|
||||
}
|
||||
if (!\function_exists('mb_strwidth')) {
|
||||
function mb_strwidth(?string $string, ?string $encoding = null) : int
|
||||
{
|
||||
return \WPMailSMTP\Vendor\Symfony\Polyfill\Mbstring\Mbstring::mb_strwidth((string) $string, $encoding);
|
||||
}
|
||||
}
|
||||
if (!\function_exists('mb_substr_count')) {
|
||||
function mb_substr_count(?string $haystack, ?string $needle, ?string $encoding = null) : int
|
||||
{
|
||||
return \WPMailSMTP\Vendor\Symfony\Polyfill\Mbstring\Mbstring::mb_substr_count((string) $haystack, (string) $needle, $encoding);
|
||||
}
|
||||
}
|
||||
if (!\function_exists('mb_output_handler')) {
|
||||
function mb_output_handler(?string $string, ?int $status) : string
|
||||
{
|
||||
return \WPMailSMTP\Vendor\Symfony\Polyfill\Mbstring\Mbstring::mb_output_handler((string) $string, (int) $status);
|
||||
}
|
||||
}
|
||||
if (!\function_exists('mb_http_input')) {
|
||||
function mb_http_input(?string $type = null) : array|string|false
|
||||
{
|
||||
return \WPMailSMTP\Vendor\Symfony\Polyfill\Mbstring\Mbstring::mb_http_input($type);
|
||||
}
|
||||
}
|
||||
if (!\function_exists('mb_convert_variables')) {
|
||||
function mb_convert_variables(?string $to_encoding, array|string|null $from_encoding, mixed &$var, mixed &...$vars) : string|false
|
||||
{
|
||||
return \WPMailSMTP\Vendor\Symfony\Polyfill\Mbstring\Mbstring::mb_convert_variables((string) $to_encoding, $from_encoding ?? '', $var, ...$vars);
|
||||
}
|
||||
}
|
||||
if (!\function_exists('mb_ord')) {
|
||||
function mb_ord(?string $string, ?string $encoding = null) : int|false
|
||||
{
|
||||
return \WPMailSMTP\Vendor\Symfony\Polyfill\Mbstring\Mbstring::mb_ord((string) $string, $encoding);
|
||||
}
|
||||
}
|
||||
if (!\function_exists('mb_chr')) {
|
||||
function mb_chr(?int $codepoint, ?string $encoding = null) : string|false
|
||||
{
|
||||
return \WPMailSMTP\Vendor\Symfony\Polyfill\Mbstring\Mbstring::mb_chr((int) $codepoint, $encoding);
|
||||
}
|
||||
}
|
||||
if (!\function_exists('mb_scrub')) {
|
||||
function mb_scrub(?string $string, ?string $encoding = null) : string
|
||||
{
|
||||
$encoding ??= \mb_internal_encoding();
|
||||
return \mb_convert_encoding((string) $string, $encoding, $encoding);
|
||||
}
|
||||
}
|
||||
if (!\function_exists('mb_str_split')) {
|
||||
function mb_str_split(?string $string, ?int $length = 1, ?string $encoding = null) : array
|
||||
{
|
||||
return \WPMailSMTP\Vendor\Symfony\Polyfill\Mbstring\Mbstring::mb_str_split((string) $string, (int) $length, $encoding);
|
||||
}
|
||||
}
|
||||
if (!\function_exists('WPMailSMTP\\Vendor\\mb_str_pad')) {
|
||||
function mb_str_pad(string $string, int $length, string $pad_string = ' ', int $pad_type = \STR_PAD_RIGHT, ?string $encoding = null) : string
|
||||
{
|
||||
return \WPMailSMTP\Vendor\Symfony\Polyfill\Mbstring\Mbstring::mb_str_pad($string, $length, $pad_string, $pad_type, $encoding);
|
||||
}
|
||||
}
|
||||
if (\extension_loaded('mbstring')) {
|
||||
return;
|
||||
}
|
||||
if (!\defined('MB_CASE_UPPER')) {
|
||||
\define('MB_CASE_UPPER', 0);
|
||||
}
|
||||
if (!\defined('MB_CASE_LOWER')) {
|
||||
\define('MB_CASE_LOWER', 1);
|
||||
}
|
||||
if (!\defined('MB_CASE_TITLE')) {
|
||||
\define('MB_CASE_TITLE', 2);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2015-2019 Fabien Potencier
|
||||
Copyright (c) 2015-present Fabien Potencier
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -69,8 +69,8 @@ final class Php72
|
||||
if ('\\' === \DIRECTORY_SEPARATOR) {
|
||||
return 'Windows';
|
||||
}
|
||||
$map = array('Darwin' => 'Darwin', 'DragonFly' => 'BSD', 'FreeBSD' => 'BSD', 'NetBSD' => 'BSD', 'OpenBSD' => 'BSD', 'Linux' => 'Linux', 'SunOS' => 'Solaris');
|
||||
return isset($map[\PHP_OS]) ? $map[\PHP_OS] : 'Unknown';
|
||||
$map = ['Darwin' => 'Darwin', 'DragonFly' => 'BSD', 'FreeBSD' => 'BSD', 'NetBSD' => 'BSD', 'OpenBSD' => 'BSD', 'Linux' => 'Linux', 'SunOS' => 'Solaris'];
|
||||
return $map[\PHP_OS] ?? 'Unknown';
|
||||
}
|
||||
public static function spl_object_id($object)
|
||||
{
|
||||
@@ -118,10 +118,10 @@ final class Php72
|
||||
}
|
||||
private static function initHashMask()
|
||||
{
|
||||
$obj = (object) array();
|
||||
$obj = (object) [];
|
||||
self::$hashMask = -1;
|
||||
// check if we are nested in an output buffering handler to prevent a fatal error with ob_start() below
|
||||
$obFuncs = array('ob_clean', 'ob_end_clean', 'ob_flush', 'ob_end_flush', 'ob_get_contents', 'ob_get_flush');
|
||||
$obFuncs = ['ob_clean', 'ob_end_clean', 'ob_flush', 'ob_end_flush', 'ob_get_contents', 'ob_get_flush'];
|
||||
foreach (\debug_backtrace(\PHP_VERSION_ID >= 50400 ? \DEBUG_BACKTRACE_IGNORE_ARGS : \false) as $frame) {
|
||||
if (isset($frame['function'][0]) && !isset($frame['class']) && 'o' === $frame['function'][0] && \in_array($frame['function'], $obFuncs)) {
|
||||
$frame['line'] = 0;
|
||||
@@ -146,7 +146,7 @@ final class Php72
|
||||
} else {
|
||||
$s = \chr(0xf0 | $code >> 18) . \chr(0x80 | $code >> 12 & 0x3f) . \chr(0x80 | $code >> 6 & 0x3f) . \chr(0x80 | $code & 0x3f);
|
||||
}
|
||||
if ('UTF-8' !== $encoding) {
|
||||
if ('UTF-8' !== ($encoding = $encoding ?? \mb_internal_encoding())) {
|
||||
$s = \mb_convert_encoding($s, $encoding, 'UTF-8');
|
||||
}
|
||||
return $s;
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
use WPMailSMTP\Vendor\Symfony\Polyfill\Php72 as p;
|
||||
|
||||
if (PHP_VERSION_ID >= 70200) {
|
||||
if (\PHP_VERSION_ID >= 70200) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ if (!defined('PHP_OS_FAMILY')) {
|
||||
define('PHP_OS_FAMILY', p\Php72::php_os_family());
|
||||
}
|
||||
|
||||
if ('\\' === DIRECTORY_SEPARATOR && !function_exists('sapi_windows_vt100_support')) {
|
||||
if ('\\' === \DIRECTORY_SEPARATOR && !function_exists('sapi_windows_vt100_support')) {
|
||||
function sapi_windows_vt100_support($stream, $enable = null) { return p\Php72::sapi_windows_vt100_support($stream, $enable); }
|
||||
}
|
||||
if (!function_exists('stream_isatty')) {
|
||||
|
||||
Reference in New Issue
Block a user