updated plugin WP Mail SMTP version 2.0.1

This commit is contained in:
KawaiiPunk 2020-05-10 13:10:06 +00:00 committed by Gitium
parent 57b2d39b8f
commit 04443ddae8
39 changed files with 334 additions and 4319 deletions

View File

@ -1,13 +1,13 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: WP Mail SMTP 2.0.0\n" "Project-Id-Version: WP Mail SMTP 2.0.1\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/wp-mail-smtp\n" "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/wp-mail-smtp\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2020-04-27T12:51:41+03:00\n" "POT-Creation-Date: 2020-05-07T15:56:11+03:00\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"X-Generator: WP-CLI 2.4.0\n" "X-Generator: WP-CLI 2.4.0\n"
"X-Domain: wp-mail-smtp\n" "X-Domain: wp-mail-smtp\n"
@ -465,45 +465,45 @@ msgstr ""
msgid "The value of this field was set using a constant %1$s most likely inside %2$s of your WordPress installation." msgid "The value of this field was set using a constant %1$s most likely inside %2$s of your WordPress installation."
msgstr "" msgstr ""
#. translators: %1$s - constant to use; %2$s - file to put that constant in. #. translators: %s - file to put that constant in.
#: src/Admin/Pages/MiscTab.php:92 #: src/Admin/Pages/MiscTab.php:92
msgid "If you want to disable using a constant, put %1$s in your %2$s file." msgid "If you want to enable this option using constants, put the lines below to your %s file:"
msgstr "" msgstr ""
#: src/Admin/Pages/MiscTab.php:106 #: src/Admin/Pages/MiscTab.php:111
msgid "Hide Announcements" msgid "Hide Announcements"
msgstr "" msgstr ""
#: src/Admin/Pages/MiscTab.php:115 #: src/Admin/Pages/MiscTab.php:120
msgid "Check this if you would like to hide plugin announcements and update details." msgid "Check this if you would like to hide plugin announcements and update details."
msgstr "" msgstr ""
#: src/Admin/Pages/MiscTab.php:125 #: src/Admin/Pages/MiscTab.php:130
msgid "Hide Email Delivery Errors" msgid "Hide Email Delivery Errors"
msgstr "" msgstr ""
#: src/Admin/Pages/MiscTab.php:141 #: src/Admin/Pages/MiscTab.php:146
msgid "Check this if you would like to hide warnings alerting of email delivery errors." msgid "Check this if you would like to hide warnings alerting of email delivery errors."
msgstr "" msgstr ""
#. translators: %s - filter that was used to disabled. #. translators: %s - filter that was used to disabled.
#: src/Admin/Pages/MiscTab.php:148 #: src/Admin/Pages/MiscTab.php:153
msgid "Email Delivery Errors were disabled using a %s filter." msgid "Email Delivery Errors were disabled using a %s filter."
msgstr "" msgstr ""
#: src/Admin/Pages/MiscTab.php:157 #: src/Admin/Pages/MiscTab.php:162
msgid "<strong>This is not recommended</strong> and should only be done for staging or development sites." msgid "<strong>This is not recommended</strong> and should only be done for staging or development sites."
msgstr "" msgstr ""
#: src/Admin/Pages/MiscTab.php:172 #: src/Admin/Pages/MiscTab.php:177
msgid "Uninstall WP Mail SMTP" msgid "Uninstall WP Mail SMTP"
msgstr "" msgstr ""
#: src/Admin/Pages/MiscTab.php:180 #: src/Admin/Pages/MiscTab.php:185
msgid "Check this if you would like to remove ALL WP Mail SMTP data upon plugin deletion. All settings will be unrecoverable." msgid "Check this if you would like to remove ALL WP Mail SMTP data upon plugin deletion. All settings will be unrecoverable."
msgstr "" msgstr ""
#: src/Admin/Pages/MiscTab.php:215 #: src/Admin/Pages/MiscTab.php:220
#: src/Admin/Pages/SettingsTab.php:540 #: src/Admin/Pages/SettingsTab.php:540
msgid "Settings were successfully saved." msgid "Settings were successfully saved."
msgstr "" msgstr ""

View File

@ -3,7 +3,7 @@ Contributors: wpforms, jaredatch, smub, slaFFik
Tags: smtp, wp mail smtp, wordpress smtp, gmail smtp, sendgrid smtp, mailgun smtp, mail, mailer, phpmailer, wp_mail, email, mailgun, sengrid, gmail, pepipost, sendinblue, wp smtp Tags: smtp, wp mail smtp, wordpress smtp, gmail smtp, sendgrid smtp, mailgun smtp, mail, mailer, phpmailer, wp_mail, email, mailgun, sengrid, gmail, pepipost, sendinblue, wp smtp
Requires at least: 4.9 Requires at least: 4.9
Tested up to: 5.4 Tested up to: 5.4
Stable tag: 2.0.0 Stable tag: 2.0.1
Requires PHP: 5.5.0 Requires PHP: 5.5.0
The most popular WordPress SMTP and PHP Mailer plugin. Trusted by over 1 million sites. The most popular WordPress SMTP and PHP Mailer plugin. Trusted by over 1 million sites.
@ -229,6 +229,11 @@ By all means please contact us to discuss features or options you'd like to see
== Changelog == == Changelog ==
= 2.0.1 - 2020-05-07 =
* Changed: Improved description of the "Do Not Send" plugin option.
* Fixed: Due to Pepipost API changes we now convert new lines so they are preserved in plain text emails.
* Fixed: Downgrade internal Guzzle dependency to 6.4 to temporarily fix compatibility issues with WordPress and Guzzle 6.5. Affects Gmail mailer.
= 2.0.0 - 2020-04-27 = = 2.0.0 - 2020-04-27 =
* IMPORTANT: Support for PHP 5.2-5.4 has been discontinued. If you are running one of those versions, you MUST upgrade PHP before installing or upgrading to WP Mail SMTP v2.0. Failure to do that will disable WP Mail SMTP functionality. * IMPORTANT: Support for PHP 5.2-5.4 has been discontinued. If you are running one of those versions, you MUST upgrade PHP before installing or upgrading to WP Mail SMTP v2.0. Failure to do that will disable WP Mail SMTP functionality.
* Added: new mailer - SMTP.com integration. * Added: new mailer - SMTP.com integration.

View File

@ -88,14 +88,19 @@ class MiscTab extends PageAbstract {
'<code>wp-config.php</code>' '<code>wp-config.php</code>'
); );
} else { } else {
printf( /* translators: %1$s - constant to use; %2$s - file to put that constant in. */ printf( /* translators: %s - file to put that constant in. */
esc_html__( 'If you want to disable using a constant, put %1$s in your %2$s file.', 'wp-mail-smtp' ), esc_html__( 'If you want to enable this option using constants, put the lines below to your %s file:', 'wp-mail-smtp' ),
'<code>define( \'WPMS_DO_NOT_SEND\', true );</code>',
'<code>wp-config.php</code>' '<code>wp-config.php</code>'
); );
} }
?> ?>
</p> </p>
<?php if ( ! $options->is_const_defined( 'general', 'do_not_send' ) ) : ?>
<pre>
define( 'WPMS_ON', true );
define( 'WPMS_DO_NOT_SEND', true );
</pre>
<?php endif; ?>
</div> </div>
</div> </div>

View File

@ -186,6 +186,8 @@ class Mailer extends MailerAbstract {
if ( $type === 'html' ) { if ( $type === 'html' ) {
$content_type = 'text/html'; $content_type = 'text/html';
} else {
$content_value = nl2br( $content_value );
} }
$data[] = array( $data[] = array(
@ -205,6 +207,7 @@ class Mailer extends MailerAbstract {
if ( $this->phpmailer->ContentType === 'text/plain' ) { if ( $this->phpmailer->ContentType === 'text/plain' ) {
$data['type'] = 'text/plain'; $data['type'] = 'text/plain';
$data['value'] = nl2br( $data['value'] );
} }
$this->set_body_param( $this->set_body_param(

View File

@ -9,9 +9,6 @@ return array(
'7b11c4dc42b3b3023073cb14e519683c' => $vendorDir . '/ralouphie/getallheaders/src/getallheaders.php', '7b11c4dc42b3b3023073cb14e519683c' => $vendorDir . '/ralouphie/getallheaders/src/getallheaders.php',
'a0edc8309cc5e1d60e3047b5df6b7052' => $vendorDir . '/guzzlehttp/psr7/src/functions_include.php', 'a0edc8309cc5e1d60e3047b5df6b7052' => $vendorDir . '/guzzlehttp/psr7/src/functions_include.php',
'c964ee0ededf28c96ebd9db5099ef910' => $vendorDir . '/guzzlehttp/promises/src/functions_include.php', 'c964ee0ededf28c96ebd9db5099ef910' => $vendorDir . '/guzzlehttp/promises/src/functions_include.php',
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php',
'25072dd6e2470089de65ae7bf11d3109' => $vendorDir . '/symfony/polyfill-php72/bootstrap.php',
'f598d06aa772fa33d905e87be6398fb1' => $vendorDir . '/symfony/polyfill-intl-idn/bootstrap.php',
'37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php', '37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php',
'decc78cc4436b1292c6c0d151b19445c' => $vendorDir . '/phpseclib/phpseclib/phpseclib/bootstrap.php', 'decc78cc4436b1292c6c0d151b19445c' => $vendorDir . '/phpseclib/phpseclib/phpseclib/bootstrap.php',
); );

View File

@ -8,9 +8,6 @@ $baseDir = dirname($vendorDir);
return array( return array(
'phpseclib\\' => array($vendorDir . '/phpseclib/phpseclib/phpseclib'), 'phpseclib\\' => array($vendorDir . '/phpseclib/phpseclib/phpseclib'),
'WPMailSMTP\\' => array($baseDir . '/src'), 'WPMailSMTP\\' => array($baseDir . '/src'),
'Symfony\\Polyfill\\Php72\\' => array($vendorDir . '/symfony/polyfill-php72'),
'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'),
'Symfony\\Polyfill\\Intl\\Idn\\' => array($vendorDir . '/symfony/polyfill-intl-idn'),
'SendinBlue\\Client\\' => array($vendorDir . '/sendinblue/api-v3-sdk/lib'), 'SendinBlue\\Client\\' => array($vendorDir . '/sendinblue/api-v3-sdk/lib'),
'Psr\\Log\\' => array($vendorDir . '/psr/log/Psr/Log'), 'Psr\\Log\\' => array($vendorDir . '/psr/log/Psr/Log'),
'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-message/src'), 'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-message/src'),

View File

@ -10,9 +10,6 @@ class ComposerStaticInit72f613a3d0c2cc77892490951b6e5352
'7b11c4dc42b3b3023073cb14e519683c' => __DIR__ . '/..' . '/ralouphie/getallheaders/src/getallheaders.php', '7b11c4dc42b3b3023073cb14e519683c' => __DIR__ . '/..' . '/ralouphie/getallheaders/src/getallheaders.php',
'a0edc8309cc5e1d60e3047b5df6b7052' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/functions_include.php', 'a0edc8309cc5e1d60e3047b5df6b7052' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/functions_include.php',
'c964ee0ededf28c96ebd9db5099ef910' => __DIR__ . '/..' . '/guzzlehttp/promises/src/functions_include.php', 'c964ee0ededf28c96ebd9db5099ef910' => __DIR__ . '/..' . '/guzzlehttp/promises/src/functions_include.php',
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
'25072dd6e2470089de65ae7bf11d3109' => __DIR__ . '/..' . '/symfony/polyfill-php72/bootstrap.php',
'f598d06aa772fa33d905e87be6398fb1' => __DIR__ . '/..' . '/symfony/polyfill-intl-idn/bootstrap.php',
'37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php', '37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php',
'decc78cc4436b1292c6c0d151b19445c' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/bootstrap.php', 'decc78cc4436b1292c6c0d151b19445c' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/bootstrap.php',
); );
@ -28,9 +25,6 @@ class ComposerStaticInit72f613a3d0c2cc77892490951b6e5352
), ),
'S' => 'S' =>
array ( array (
'Symfony\\Polyfill\\Php72\\' => 23,
'Symfony\\Polyfill\\Mbstring\\' => 26,
'Symfony\\Polyfill\\Intl\\Idn\\' => 26,
'SendinBlue\\Client\\' => 18, 'SendinBlue\\Client\\' => 18,
), ),
'P' => 'P' =>
@ -69,18 +63,6 @@ class ComposerStaticInit72f613a3d0c2cc77892490951b6e5352
array ( array (
0 => __DIR__ . '/../..' . '/src', 0 => __DIR__ . '/../..' . '/src',
), ),
'Symfony\\Polyfill\\Php72\\' =>
array (
0 => __DIR__ . '/..' . '/symfony/polyfill-php72',
),
'Symfony\\Polyfill\\Mbstring\\' =>
array (
0 => __DIR__ . '/..' . '/symfony/polyfill-mbstring',
),
'Symfony\\Polyfill\\Intl\\Idn\\' =>
array (
0 => __DIR__ . '/..' . '/symfony/polyfill-intl-idn',
),
'SendinBlue\\Client\\' => 'SendinBlue\\Client\\' =>
array ( array (
0 => __DIR__ . '/..' . '/sendinblue/api-v3-sdk/lib', 0 => __DIR__ . '/..' . '/sendinblue/api-v3-sdk/lib',

View File

@ -2,12 +2,11 @@
namespace GuzzleHttp; namespace GuzzleHttp;
use GuzzleHttp\Cookie\CookieJar; use GuzzleHttp\Cookie\CookieJar;
use GuzzleHttp\Exception\InvalidArgumentException;
use GuzzleHttp\Promise; use GuzzleHttp\Promise;
use GuzzleHttp\Psr7; use GuzzleHttp\Psr7;
use Psr\Http\Message\UriInterface;
use Psr\Http\Message\RequestInterface; use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\UriInterface;
/** /**
* @method ResponseInterface get(string|UriInterface $uri, array $options = []) * @method ResponseInterface get(string|UriInterface $uri, array $options = [])
@ -76,12 +75,6 @@ class Client implements ClientInterface
$this->configureDefaults($config); $this->configureDefaults($config);
} }
/**
* @param string $method
* @param array $args
*
* @return Promise\PromiseInterface
*/
public function __call($method, $args) public function __call($method, $args)
{ {
if (count($args) < 1) { if (count($args) < 1) {
@ -96,14 +89,6 @@ class Client implements ClientInterface
: $this->request($method, $uri, $opts); : $this->request($method, $uri, $opts);
} }
/**
* Asynchronously send an HTTP request.
*
* @param array $options Request options to apply to the given
* request and to the transfer. See \GuzzleHttp\RequestOptions.
*
* @return Promise\PromiseInterface
*/
public function sendAsync(RequestInterface $request, array $options = []) public function sendAsync(RequestInterface $request, array $options = [])
{ {
// Merge the base URI into the request URI if needed. // Merge the base URI into the request URI if needed.
@ -115,35 +100,12 @@ class Client implements ClientInterface
); );
} }
/**
* Send an HTTP request.
*
* @param array $options Request options to apply to the given
* request and to the transfer. See \GuzzleHttp\RequestOptions.
*
* @return ResponseInterface
* @throws GuzzleException
*/
public function send(RequestInterface $request, array $options = []) public function send(RequestInterface $request, array $options = [])
{ {
$options[RequestOptions::SYNCHRONOUS] = true; $options[RequestOptions::SYNCHRONOUS] = true;
return $this->sendAsync($request, $options)->wait(); return $this->sendAsync($request, $options)->wait();
} }
/**
* Create and send an asynchronous HTTP request.
*
* Use an absolute path to override the base path of the client, or a
* relative path to append to the base path of the client. The URL can
* contain the query string as well. Use an array to provide a URL
* template and additional variables to use in the URL template expansion.
*
* @param string $method HTTP method
* @param string|UriInterface $uri URI object or string.
* @param array $options Request options to apply. See \GuzzleHttp\RequestOptions.
*
* @return Promise\PromiseInterface
*/
public function requestAsync($method, $uri = '', array $options = []) public function requestAsync($method, $uri = '', array $options = [])
{ {
$options = $this->prepareDefaults($options); $options = $this->prepareDefaults($options);
@ -163,37 +125,12 @@ class Client implements ClientInterface
return $this->transfer($request, $options); return $this->transfer($request, $options);
} }
/**
* Create and send an HTTP request.
*
* Use an absolute path to override the base path of the client, or a
* relative path to append to the base path of the client. The URL can
* contain the query string as well.
*
* @param string $method HTTP method.
* @param string|UriInterface $uri URI object or string.
* @param array $options Request options to apply. See \GuzzleHttp\RequestOptions.
*
* @return ResponseInterface
* @throws GuzzleException
*/
public function request($method, $uri = '', array $options = []) public function request($method, $uri = '', array $options = [])
{ {
$options[RequestOptions::SYNCHRONOUS] = true; $options[RequestOptions::SYNCHRONOUS] = true;
return $this->requestAsync($method, $uri, $options)->wait(); return $this->requestAsync($method, $uri, $options)->wait();
} }
/**
* Get a client configuration option.
*
* These options include default request options of the client, a "handler"
* (if utilized by the concrete client), and a "base_uri" if utilized by
* the concrete client.
*
* @param string|null $option The config option to retrieve.
*
* @return mixed
*/
public function getConfig($option = null) public function getConfig($option = null)
{ {
return $option === null return $option === null
@ -201,11 +138,6 @@ class Client implements ClientInterface
: (isset($this->config[$option]) ? $this->config[$option] : null); : (isset($this->config[$option]) ? $this->config[$option] : null);
} }
/**
* @param string|null $uri
*
* @return UriInterface
*/
private function buildUri($uri, array $config) private function buildUri($uri, array $config)
{ {
// for BC we accept null which would otherwise fail in uri_for // for BC we accept null which would otherwise fail in uri_for
@ -215,11 +147,6 @@ class Client implements ClientInterface
$uri = Psr7\UriResolver::resolve(Psr7\uri_for($config['base_uri']), $uri); $uri = Psr7\UriResolver::resolve(Psr7\uri_for($config['base_uri']), $uri);
} }
if (isset($config['idn_conversion']) && ($config['idn_conversion'] !== false)) {
$idnOptions = ($config['idn_conversion'] === true) ? IDNA_DEFAULT : $config['idn_conversion'];
$uri = Utils::idnUriConvert($uri, $idnOptions);
}
return $uri->getScheme() === '' && $uri->getHost() !== '' ? $uri->withScheme('http') : $uri; return $uri->getScheme() === '' && $uri->getHost() !== '' ? $uri->withScheme('http') : $uri;
} }
@ -227,7 +154,6 @@ class Client implements ClientInterface
* Configures the default options for a client. * Configures the default options for a client.
* *
* @param array $config * @param array $config
* @return void
*/ */
private function configureDefaults(array $config) private function configureDefaults(array $config)
{ {
@ -236,8 +162,7 @@ class Client implements ClientInterface
'http_errors' => true, 'http_errors' => true,
'decode_content' => true, 'decode_content' => true,
'verify' => true, 'verify' => true,
'cookies' => false, 'cookies' => false
'idn_conversion' => true,
]; ];
// Use the standard Linux HTTP_PROXY and HTTPS_PROXY if set. // Use the standard Linux HTTP_PROXY and HTTPS_PROXY if set.
@ -245,7 +170,7 @@ class Client implements ClientInterface
// We can only trust the HTTP_PROXY environment variable in a CLI // We can only trust the HTTP_PROXY environment variable in a CLI
// process due to the fact that PHP has no reliable mechanism to // process due to the fact that PHP has no reliable mechanism to
// get environment variables that start with "HTTP_". // get environment variables that start with "HTTP_".
if (php_sapi_name() === 'cli' && getenv('HTTP_PROXY')) { if (php_sapi_name() == 'cli' && getenv('HTTP_PROXY')) {
$defaults['proxy']['http'] = getenv('HTTP_PROXY'); $defaults['proxy']['http'] = getenv('HTTP_PROXY');
} }
@ -300,7 +225,7 @@ class Client implements ClientInterface
if (array_key_exists('headers', $options)) { if (array_key_exists('headers', $options)) {
// Allows default headers to be unset. // Allows default headers to be unset.
if ($options['headers'] === null) { if ($options['headers'] === null) {
$defaults['_conditional'] = []; $defaults['_conditional'] = null;
unset($options['headers']); unset($options['headers']);
} elseif (!is_array($options['headers'])) { } elseif (!is_array($options['headers'])) {
throw new \InvalidArgumentException('headers must be an array'); throw new \InvalidArgumentException('headers must be an array');
@ -326,7 +251,8 @@ class Client implements ClientInterface
* The URI of the request is not modified and the request options are used * The URI of the request is not modified and the request options are used
* as-is without merging in default options. * as-is without merging in default options.
* *
* @param array $options See \GuzzleHttp\RequestOptions. * @param RequestInterface $request
* @param array $options
* *
* @return Promise\PromiseInterface * @return Promise\PromiseInterface
*/ */
@ -345,7 +271,6 @@ class Client implements ClientInterface
} }
$request = $this->applyOptions($request, $options); $request = $this->applyOptions($request, $options);
/** @var HandlerStack $handler */
$handler = $options['handler']; $handler = $options['handler'];
try { try {
@ -486,11 +411,6 @@ class Client implements ClientInterface
return $request; return $request;
} }
/**
* Throw Exception with pre-set message.
* @return void
* @throws InvalidArgumentException Invalid body.
*/
private function invalidBody() private function invalidBody()
{ {
throw new \InvalidArgumentException('Passing in the "body" request ' throw new \InvalidArgumentException('Passing in the "body" request '

View File

@ -1,8 +1,8 @@
<?php <?php
namespace GuzzleHttp; namespace GuzzleHttp;
use GuzzleHttp\Exception\GuzzleException;
use GuzzleHttp\Promise\PromiseInterface; use GuzzleHttp\Promise\PromiseInterface;
use GuzzleHttp\Exception\GuzzleException;
use Psr\Http\Message\RequestInterface; use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\UriInterface; use Psr\Http\Message\UriInterface;
@ -12,10 +12,7 @@ use Psr\Http\Message\UriInterface;
*/ */
interface ClientInterface interface ClientInterface
{ {
/** const VERSION = '6.4.1';
* @deprecated Will be removed in Guzzle 7.0.0
*/
const VERSION = '6.5.3';
/** /**
* Send an HTTP request. * Send an HTTP request.

View File

@ -94,8 +94,8 @@ class CookieJar implements CookieJarInterface
*/ */
public function getCookieByName($name) public function getCookieByName($name)
{ {
// don't allow a non string name // don't allow a null name
if ($name === null || !is_scalar($name)) { if ($name === null) {
return null; return null;
} }
foreach ($this->cookies as $cookie) { foreach ($this->cookies as $cookie) {
@ -103,8 +103,6 @@ class CookieJar implements CookieJarInterface
return $cookie; return $cookie;
} }
} }
return null;
} }
public function toArray() public function toArray()

View File

@ -58,9 +58,9 @@ interface CookieJarInterface extends \Countable, \IteratorAggregate
* arguments, then the cookie with the specified name, path and domain is * arguments, then the cookie with the specified name, path and domain is
* removed. * removed.
* *
* @param string|null $domain Clears cookies matching a domain * @param string $domain Clears cookies matching a domain
* @param string|null $path Clears cookies matching a domain and path * @param string $path Clears cookies matching a domain and path
* @param string|null $name Clears cookies matching a domain, path, and name * @param string $name Clears cookies matching a domain, path, and name
* *
* @return CookieJarInterface * @return CookieJarInterface
*/ */

View File

@ -1,9 +1,9 @@
<?php <?php
namespace GuzzleHttp\Exception; namespace GuzzleHttp\Exception;
use GuzzleHttp\Promise\PromiseInterface;
use Psr\Http\Message\RequestInterface; use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseInterface;
use GuzzleHttp\Promise\PromiseInterface;
use Psr\Http\Message\UriInterface; use Psr\Http\Message\UriInterface;
/** /**
@ -14,7 +14,7 @@ class RequestException extends TransferException
/** @var RequestInterface */ /** @var RequestInterface */
private $request; private $request;
/** @var ResponseInterface|null */ /** @var ResponseInterface */
private $response; private $response;
/** @var array */ /** @var array */
@ -124,17 +124,42 @@ class RequestException extends TransferException
*/ */
public static function getResponseBodySummary(ResponseInterface $response) public static function getResponseBodySummary(ResponseInterface $response)
{ {
return \GuzzleHttp\Psr7\get_message_body_summary($response); $body = $response->getBody();
if (!$body->isSeekable() || !$body->isReadable()) {
return null;
}
$size = $body->getSize();
if ($size === 0) {
return null;
}
$summary = $body->read(120);
$body->rewind();
if ($size > 120) {
$summary .= ' (truncated...)';
}
// Matches any printable character, including unicode characters:
// letters, marks, numbers, punctuation, spacing, and separators.
if (preg_match('/[^\pL\pM\pN\pP\pS\pZ\n\r\t]/', $summary)) {
return null;
}
return $summary;
} }
/** /**
* Obfuscates URI if there is a username and a password present * Obfuscates URI if there is an username and a password present
* *
* @param UriInterface $uri * @param UriInterface $uri
* *
* @return UriInterface * @return UriInterface
*/ */
private static function obfuscateUri(UriInterface $uri) private static function obfuscateUri($uri)
{ {
$userInfo = $uri->getUserInfo(); $userInfo = $uri->getUserInfo();

View File

@ -1,8 +1,8 @@
<?php <?php
namespace GuzzleHttp\Handler; namespace GuzzleHttp\Handler;
use GuzzleHttp\Exception\ConnectException;
use GuzzleHttp\Exception\RequestException; use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Exception\ConnectException;
use GuzzleHttp\Promise\FulfilledPromise; use GuzzleHttp\Promise\FulfilledPromise;
use GuzzleHttp\Psr7; use GuzzleHttp\Psr7;
use GuzzleHttp\Psr7\LazyOpenStream; use GuzzleHttp\Psr7\LazyOpenStream;
@ -454,16 +454,11 @@ class CurlFactory implements CurlFactoryInterface
} }
if (isset($options['ssl_key'])) { if (isset($options['ssl_key'])) {
if (is_array($options['ssl_key'])) { $sslKey = $options['ssl_key'];
if (count($options['ssl_key']) === 2) { if (is_array($sslKey)) {
list($sslKey, $conf[CURLOPT_SSLKEYPASSWD]) = $options['ssl_key']; $conf[CURLOPT_SSLKEYPASSWD] = $sslKey[1];
} else { $sslKey = $sslKey[0];
list($sslKey) = $options['ssl_key'];
} }
}
$sslKey = isset($sslKey) ? $sslKey: $options['ssl_key'];
if (!file_exists($sslKey)) { if (!file_exists($sslKey)) {
throw new \InvalidArgumentException( throw new \InvalidArgumentException(
"SSL private key not found: {$sslKey}" "SSL private key not found: {$sslKey}"

View File

@ -1,10 +1,9 @@
<?php <?php
namespace GuzzleHttp\Handler; namespace GuzzleHttp\Handler;
use GuzzleHttp\Exception\InvalidArgumentException;
use GuzzleHttp\Promise as P; use GuzzleHttp\Promise as P;
use GuzzleHttp\Promise\Promise; use GuzzleHttp\Promise\Promise;
use GuzzleHttp\Utils; use GuzzleHttp\Psr7;
use Psr\Http\Message\RequestInterface; use Psr\Http\Message\RequestInterface;
/** /**
@ -24,7 +23,6 @@ class CurlMultiHandler
private $active; private $active;
private $handles = []; private $handles = [];
private $delays = []; private $delays = [];
private $options = [];
/** /**
* This handler accepts the following options: * This handler accepts the following options:
@ -32,8 +30,6 @@ class CurlMultiHandler
* - handle_factory: An optional factory used to create curl handles * - handle_factory: An optional factory used to create curl handles
* - select_timeout: Optional timeout (in seconds) to block before timing * - select_timeout: Optional timeout (in seconds) to block before timing
* out while selecting curl handles. Defaults to 1 second. * out while selecting curl handles. Defaults to 1 second.
* - options: An associative array of CURLMOPT_* options and
* corresponding values for curl_multi_setopt()
* *
* @param array $options * @param array $options
*/ */
@ -49,23 +45,12 @@ class CurlMultiHandler
} else { } else {
$this->selectTimeout = 1; $this->selectTimeout = 1;
} }
$this->options = isset($options['options']) ? $options['options'] : [];
} }
public function __get($name) public function __get($name)
{ {
if ($name === '_mh') { if ($name === '_mh') {
$this->_mh = curl_multi_init(); return $this->_mh = curl_multi_init();
foreach ($this->options as $option => $value) {
// A warning is raised in case of a wrong option.
curl_multi_setopt($this->_mh, $option, $value);
}
// Further calls to _mh will return the value directly, without entering the
// __get() method at all.
return $this->_mh;
} }
throw new \BadMethodCallException(); throw new \BadMethodCallException();
@ -103,7 +88,7 @@ class CurlMultiHandler
{ {
// Add any delayed handles if needed. // Add any delayed handles if needed.
if ($this->delays) { if ($this->delays) {
$currentTime = Utils::currentTime(); $currentTime = \GuzzleHttp\_current_time();
foreach ($this->delays as $id => $delay) { foreach ($this->delays as $id => $delay) {
if ($currentTime >= $delay) { if ($currentTime >= $delay) {
unset($this->delays[$id]); unset($this->delays[$id]);
@ -155,7 +140,7 @@ class CurlMultiHandler
if (empty($easy->options['delay'])) { if (empty($easy->options['delay'])) {
curl_multi_add_handle($this->_mh, $easy->handle); curl_multi_add_handle($this->_mh, $easy->handle);
} else { } else {
$this->delays[$id] = Utils::currentTime() + ($easy->options['delay'] / 1000); $this->delays[$id] = \GuzzleHttp\_current_time() + ($easy->options['delay'] / 1000);
} }
} }
@ -207,7 +192,7 @@ class CurlMultiHandler
private function timeToNext() private function timeToNext()
{ {
$currentTime = Utils::currentTime(); $currentTime = \GuzzleHttp\_current_time();
$nextTime = PHP_INT_MAX; $nextTime = PHP_INT_MAX;
foreach ($this->delays as $time) { foreach ($this->delays as $time) {
if ($time < $nextTime) { if ($time < $nextTime) {

View File

@ -66,7 +66,7 @@ class MockHandler implements \Countable
throw new \OutOfBoundsException('Mock queue is empty'); throw new \OutOfBoundsException('Mock queue is empty');
} }
if (isset($options['delay']) && is_numeric($options['delay'])) { if (isset($options['delay'])) {
usleep($options['delay'] * 1000); usleep($options['delay'] * 1000);
} }
@ -175,11 +175,6 @@ class MockHandler implements \Countable
return count($this->queue); return count($this->queue);
} }
public function reset()
{
$this->queue = [];
}
private function invokeStats( private function invokeStats(
RequestInterface $request, RequestInterface $request,
array $options, array $options,

View File

@ -1,13 +1,12 @@
<?php <?php
namespace GuzzleHttp\Handler; namespace GuzzleHttp\Handler;
use GuzzleHttp\Exception\ConnectException;
use GuzzleHttp\Exception\RequestException; use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Exception\ConnectException;
use GuzzleHttp\Promise\FulfilledPromise; use GuzzleHttp\Promise\FulfilledPromise;
use GuzzleHttp\Promise\PromiseInterface; use GuzzleHttp\Promise\PromiseInterface;
use GuzzleHttp\Psr7; use GuzzleHttp\Psr7;
use GuzzleHttp\TransferStats; use GuzzleHttp\TransferStats;
use GuzzleHttp\Utils;
use Psr\Http\Message\RequestInterface; use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamInterface; use Psr\Http\Message\StreamInterface;
@ -34,7 +33,7 @@ class StreamHandler
usleep($options['delay'] * 1000); usleep($options['delay'] * 1000);
} }
$startTime = isset($options['on_stats']) ? Utils::currentTime() : null; $startTime = isset($options['on_stats']) ? \GuzzleHttp\_current_time() : null;
try { try {
// Does not support the expect header. // Does not support the expect header.
@ -83,7 +82,7 @@ class StreamHandler
$stats = new TransferStats( $stats = new TransferStats(
$request, $request,
$response, $response,
Utils::currentTime() - $startTime, \GuzzleHttp\_current_time() - $startTime,
$error, $error,
[] []
); );

View File

@ -1,9 +1,7 @@
<?php <?php
namespace GuzzleHttp; namespace GuzzleHttp;
use GuzzleHttp\Promise\PromiseInterface;
use Psr\Http\Message\RequestInterface; use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
/** /**
* Creates a composed Guzzle handler function by stacking middlewares on top of * Creates a composed Guzzle handler function by stacking middlewares on top of
@ -11,7 +9,7 @@ use Psr\Http\Message\ResponseInterface;
*/ */
class HandlerStack class HandlerStack
{ {
/** @var callable|null */ /** @var callable */
private $handler; private $handler;
/** @var array */ /** @var array */
@ -61,8 +59,6 @@ class HandlerStack
* *
* @param RequestInterface $request * @param RequestInterface $request
* @param array $options * @param array $options
*
* @return ResponseInterface|PromiseInterface
*/ */
public function __invoke(RequestInterface $request, array $options) public function __invoke(RequestInterface $request, array $options)
{ {

View File

@ -168,11 +168,6 @@ class MessageFormatter
); );
} }
/**
* Get headers from message as string
*
* @return string
*/
private function headers(MessageInterface $message) private function headers(MessageInterface $message)
{ {
$result = ''; $result = '';

View File

@ -1,10 +1,9 @@
<?php <?php
namespace GuzzleHttp; namespace GuzzleHttp;
use GuzzleHttp\Promise\EachPromise;
use GuzzleHttp\Promise\PromiseInterface;
use GuzzleHttp\Promise\PromisorInterface; use GuzzleHttp\Promise\PromisorInterface;
use Psr\Http\Message\RequestInterface; use Psr\Http\Message\RequestInterface;
use GuzzleHttp\Promise\EachPromise;
/** /**
* Sends an iterator of requests concurrently using a capped pool size. * Sends an iterator of requests concurrently using a capped pool size.
@ -70,11 +69,6 @@ class Pool implements PromisorInterface
$this->each = new EachPromise($requests(), $config); $this->each = new EachPromise($requests(), $config);
} }
/**
* Get promise
*
* @return PromiseInterface
*/
public function promise() public function promise()
{ {
return $this->each->promise(); return $this->each->promise();
@ -112,11 +106,6 @@ class Pool implements PromisorInterface
return $res; return $res;
} }
/**
* Execute callback(s)
*
* @return void
*/
private static function cmpCallback(array &$options, $name, array &$results) private static function cmpCallback(array &$options, $name, array &$results)
{ {
if (!isset($options[$name])) { if (!isset($options[$name])) {

View File

@ -66,11 +66,6 @@ class PrepareBodyMiddleware
return $fn(Psr7\modify_request($request, $modify), $options); return $fn(Psr7\modify_request($request, $modify), $options);
} }
/**
* Add expect header
*
* @return void
*/
private function addExpectHeader( private function addExpectHeader(
RequestInterface $request, RequestInterface $request,
array $options, array $options,

View File

@ -13,7 +13,7 @@ use Psr\Http\Message\UriInterface;
* Request redirect middleware. * Request redirect middleware.
* *
* Apply this middleware like other middleware using * Apply this middleware like other middleware using
* {@see \GuzzleHttp\Middleware::redirect()}. * {@see GuzzleHttp\Middleware::redirect()}.
*/ */
class RedirectMiddleware class RedirectMiddleware
{ {
@ -76,7 +76,7 @@ class RedirectMiddleware
/** /**
* @param RequestInterface $request * @param RequestInterface $request
* @param array $options * @param array $options
* @param ResponseInterface $response * @param ResponseInterface|PromiseInterface $response
* *
* @return ResponseInterface|PromiseInterface * @return ResponseInterface|PromiseInterface
*/ */
@ -118,11 +118,6 @@ class RedirectMiddleware
return $promise; return $promise;
} }
/**
* Enable tracking on promise.
*
* @return PromiseInterface
*/
private function withTracking(PromiseInterface $promise, $uri, $statusCode) private function withTracking(PromiseInterface $promise, $uri, $statusCode)
{ {
return $promise->then( return $promise->then(
@ -140,13 +135,6 @@ class RedirectMiddleware
); );
} }
/**
* Check for too many redirects
*
* @return void
*
* @throws TooManyRedirectsException Too many redirects.
*/
private function guardMax(RequestInterface $request, array &$options) private function guardMax(RequestInterface $request, array &$options)
{ {
$current = isset($options['__redirect_count']) $current = isset($options['__redirect_count'])
@ -184,19 +172,13 @@ class RedirectMiddleware
// would do. // would do.
$statusCode = $response->getStatusCode(); $statusCode = $response->getStatusCode();
if ($statusCode == 303 || if ($statusCode == 303 ||
($statusCode <= 302 && !$options['allow_redirects']['strict']) ($statusCode <= 302 && $request->getBody() && !$options['allow_redirects']['strict'])
) { ) {
$modify['method'] = 'GET'; $modify['method'] = 'GET';
$modify['body'] = ''; $modify['body'] = '';
} }
$uri = $this->redirectUri($request, $response, $protocols); $modify['uri'] = $this->redirectUri($request, $response, $protocols);
if (isset($options['idn_conversion']) && ($options['idn_conversion'] !== false)) {
$idnOptions = ($options['idn_conversion'] === true) ? IDNA_DEFAULT : $options['idn_conversion'];
$uri = Utils::idnUriConvert($uri, $idnOptions);
}
$modify['uri'] = $uri;
Psr7\rewind_body($request); Psr7\rewind_body($request);
// Add the Referer header if it is told to do so and only // Add the Referer header if it is told to do so and only

View File

@ -132,14 +132,6 @@ final class RequestOptions
*/ */
const HTTP_ERRORS = 'http_errors'; const HTTP_ERRORS = 'http_errors';
/**
* idn: (bool|int, default=true) A combination of IDNA_* constants for
* idn_to_ascii() PHP's function (see "options" parameter). Set to false to
* disable IDN support completely, or to true to use the default
* configuration (IDNA_DEFAULT constant).
*/
const IDN_CONVERSION = 'idn_conversion';
/** /**
* json: (mixed) Adds JSON data to a request. The provided value is JSON * json: (mixed) Adds JSON data to a request. The provided value is JSON
* encoded and a Content-Type header of application/json will be added to * encoded and a Content-Type header of application/json will be added to

View File

@ -47,11 +47,11 @@ class RetryMiddleware
* *
* @param int $retries * @param int $retries
* *
* @return int milliseconds. * @return int
*/ */
public static function exponentialDelay($retries) public static function exponentialDelay($retries)
{ {
return (int) pow(2, $retries - 1) * 1000; return (int) pow(2, $retries - 1);
} }
/** /**
@ -74,11 +74,6 @@ class RetryMiddleware
); );
} }
/**
* Execute fulfilled closure
*
* @return mixed
*/
private function onFulfilled(RequestInterface $req, array $options) private function onFulfilled(RequestInterface $req, array $options)
{ {
return function ($value) use ($req, $options) { return function ($value) use ($req, $options) {
@ -95,11 +90,6 @@ class RetryMiddleware
}; };
} }
/**
* Execute rejected closure
*
* @return callable
*/
private function onRejected(RequestInterface $req, array $options) private function onRejected(RequestInterface $req, array $options)
{ {
return function ($reason) use ($req, $options) { return function ($reason) use ($req, $options) {
@ -116,9 +106,6 @@ class RetryMiddleware
}; };
} }
/**
* @return self
*/
private function doRetry(RequestInterface $request, array $options, ResponseInterface $response = null) private function doRetry(RequestInterface $request, array $options, ResponseInterface $response = null)
{ {
$options['delay'] = call_user_func($this->delay, ++$options['retries'], $response); $options['delay'] = call_user_func($this->delay, ++$options['retries'], $response);

View File

@ -19,7 +19,7 @@ final class TransferStats
/** /**
* @param RequestInterface $request Request that was sent. * @param RequestInterface $request Request that was sent.
* @param ResponseInterface|null $response Response received (if any) * @param ResponseInterface $response Response received (if any)
* @param float|null $transferTime Total handler transfer time. * @param float|null $transferTime Total handler transfer time.
* @param mixed $handlerErrorData Handler error data. * @param mixed $handlerErrorData Handler error data.
* @param array $handlerStats Handler specific stats. * @param array $handlerStats Handler specific stats.
@ -93,7 +93,7 @@ final class TransferStats
/** /**
* Get the estimated time the request was being transferred by the handler. * Get the estimated time the request was being transferred by the handler.
* *
* @return float|null Time in seconds. * @return float Time in seconds.
*/ */
public function getTransferTime() public function getTransferTime()
{ {

View File

@ -1,67 +0,0 @@
<?php
namespace GuzzleHttp;
use GuzzleHttp\Exception\InvalidArgumentException;
use Psr\Http\Message\UriInterface;
final class Utils
{
/**
* Wrapper for the hrtime() or microtime() functions
* (depending on the PHP version, one of the two is used)
*
* @return float|mixed UNIX timestamp
*
* @internal
*/
public static function currentTime()
{
return function_exists('hrtime') ? hrtime(true) / 1e9 : microtime(true);
}
/**
* @param int $options
*
* @return UriInterface
* @throws InvalidArgumentException
*
* @internal
*/
public static function idnUriConvert(UriInterface $uri, $options = 0)
{
if ($uri->getHost()) {
$idnaVariant = defined('INTL_IDNA_VARIANT_UTS46') ? INTL_IDNA_VARIANT_UTS46 : 0;
$asciiHost = $idnaVariant === 0
? idn_to_ascii($uri->getHost(), $options)
: idn_to_ascii($uri->getHost(), $options, $idnaVariant, $info);
if ($asciiHost === false) {
$errorBitSet = isset($info['errors']) ? $info['errors'] : 0;
$errorConstants = array_filter(array_keys(get_defined_constants()), function ($name) {
return substr($name, 0, 11) === 'IDNA_ERROR_';
});
$errors = [];
foreach ($errorConstants as $errorConstant) {
if ($errorBitSet & constant($errorConstant)) {
$errors[] = $errorConstant;
}
}
$errorMessage = 'IDN conversion failed';
if ($errors) {
$errorMessage .= ' (errors: ' . implode(', ', $errors) . ')';
}
throw new InvalidArgumentException($errorMessage);
} else {
if ($uri->getHost() !== $asciiHost) {
// Replace URI only if the ASCII version is different
$uri = $uri->withHost($asciiHost);
}
}
}
return $uri;
}
}

View File

@ -56,7 +56,7 @@ function describe_type($input)
/** /**
* Parses an array of header lines into an associative array of headers. * Parses an array of header lines into an associative array of headers.
* *
* @param iterable $lines Header lines array of strings in the following * @param array $lines Header lines array of strings in the following
* format: "Name: Value" * format: "Name: Value"
* @return array * @return array
*/ */
@ -97,8 +97,8 @@ function debug_resource($value = null)
* *
* The returned handler is not wrapped by any default middlewares. * The returned handler is not wrapped by any default middlewares.
* *
* @return callable Returns the best handler for the given system.
* @throws \RuntimeException if no viable Handler is available. * @throws \RuntimeException if no viable Handler is available.
* @return callable Returns the best handler for the given system.
*/ */
function choose_handler() function choose_handler()
{ {
@ -332,3 +332,15 @@ function json_encode($value, $options = 0, $depth = 512)
return $json; return $json;
} }
/**
* Wrapper for the hrtime() or microtime() functions
* (depending on the PHP version, one of the two is used)
*
* @return float|mixed UNIX timestamp
* @internal
*/
function _current_time()
{
return function_exists('hrtime') ? hrtime(true) / 1e9 : microtime(true);
}

View File

@ -1,283 +0,0 @@
<?php
/*
* Copyright (c) 2014 TrueServer B.V.
*
* 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:
*
* 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
*/
namespace Symfony\Polyfill\Intl\Idn;
/**
* 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>
*
* @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())
{
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;
}
}
$output = implode('.', $parts);
$idna_info = array(
'result' => \strlen($output) > 255 ? false : $output,
'isTransitionalDifferent' => false,
'errors' => 0,
);
return $idna_info['result'];
}
public static function idn_to_utf8($domain, $options, $variant, &$idna_info = array())
{
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'];
}
private static function encodePart($input)
{
$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');
}
if ($input === $output) {
return $output;
}
if ($b > 0) {
$output .= '-';
}
$codePoints['nonBasic'] = array_unique($codePoints['nonBasic']);
sort($codePoints['nonBasic']);
$i = 0;
$length = mb_strlen($input, 'utf-8');
while ($h < $length) {
$m = $codePoints['nonBasic'][$i++];
$delta += ($m - $n) * ($h + 1);
$n = $m;
foreach ($codePoints['all'] as $c) {
if ($c < $n || $c < 128) {
++$delta;
}
if ($c === $n) {
$q = $delta;
for ($k = 36;; $k += 36) {
$t = self::calculateThreshold($k, $bias);
if ($q < $t) {
break;
}
$code = $t + (($q - $t) % (36 - $t));
$output .= self::$encodeTable[$code];
$q = ($q - $t) / (36 - $t);
}
$output .= self::$encodeTable[$q];
$bias = self::adapt($delta, $h + 1, ($h === $b));
$delta = 0;
++$h;
}
}
++$delta;
++$n;
}
$output = 'xn--'.$output;
return \strlen($output) < 1 || 63 < \strlen($output) ? false : strtolower($output);
}
private static function listCodePoints($input)
{
$codePoints = array(
'all' => array(),
'basic' => array(),
'nonBasic' => array(),
);
$length = mb_strlen($input, 'utf-8');
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;
}
}
return $codePoints;
}
private static function calculateThreshold($k, $bias)
{
if ($k <= $bias + 1) {
return 1;
}
if ($k >= $bias + 26) {
return 26;
}
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;
}
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;
}
$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;
}
$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;
}
return $output;
}
}

View File

@ -1,19 +0,0 @@
Copyright (c) 2018-2019 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
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:
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.

View File

@ -1,61 +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 Symfony\Polyfill\Intl\Idn as p;
if (!defined('IDNA_DEFAULT')) {
define('U_IDNA_PROHIBITED_ERROR', 66560);
define('U_IDNA_ERROR_START', 66560);
define('U_IDNA_UNASSIGNED_ERROR', 66561);
define('U_IDNA_CHECK_BIDI_ERROR', 66562);
define('U_IDNA_STD3_ASCII_RULES_ERROR', 66563);
define('U_IDNA_ACE_PREFIX_ERROR', 66564);
define('U_IDNA_VERIFICATION_ERROR', 66565);
define('U_IDNA_LABEL_TOO_LONG_ERROR', 66566);
define('U_IDNA_ZERO_LENGTH_LABEL_ERROR', 66567);
define('U_IDNA_DOMAIN_NAME_TOO_LONG_ERROR', 66568);
define('U_IDNA_ERROR_LIMIT', 66569);
define('U_STRINGPREP_PROHIBITED_ERROR', 66560);
define('U_STRINGPREP_UNASSIGNED_ERROR', 66561);
define('U_STRINGPREP_CHECK_BIDI_ERROR', 66562);
define('IDNA_DEFAULT', 0);
define('IDNA_ALLOW_UNASSIGNED', 1);
define('IDNA_USE_STD3_RULES', 2);
define('IDNA_CHECK_BIDI', 4);
define('IDNA_CHECK_CONTEXTJ', 8);
define('IDNA_NONTRANSITIONAL_TO_ASCII', 16);
define('IDNA_NONTRANSITIONAL_TO_UNICODE', 32);
define('INTL_IDNA_VARIANT_2003', 0);
define('INTL_IDNA_VARIANT_UTS46', 1);
define('IDNA_ERROR_EMPTY_LABEL', 1);
define('IDNA_ERROR_LABEL_TOO_LONG', 2);
define('IDNA_ERROR_DOMAIN_NAME_TOO_LONG', 4);
define('IDNA_ERROR_LEADING_HYPHEN', 8);
define('IDNA_ERROR_TRAILING_HYPHEN', 16);
define('IDNA_ERROR_HYPHEN_3_4', 32);
define('IDNA_ERROR_LEADING_COMBINING_MARK', 64);
define('IDNA_ERROR_DISALLOWED', 128);
define('IDNA_ERROR_PUNYCODE', 256);
define('IDNA_ERROR_LABEL_HAS_DOT', 512);
define('IDNA_ERROR_INVALID_ACE_LABEL', 1024);
define('IDNA_ERROR_BIDI', 2048);
define('IDNA_ERROR_CONTEXTJ', 4096);
}
if (!function_exists('idn_to_ascii')) {
if (PHP_VERSION_ID < 70400) {
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_utf8($domain, $options = IDNA_DEFAULT, $variant = INTL_IDNA_VARIANT_2003, &$idna_info = array()) { return p\Idn::idn_to_utf8($domain, $options, $variant, $idna_info); }
} else {
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_utf8($domain, $options = IDNA_DEFAULT, $variant = INTL_IDNA_VARIANT_UTS46, &$idna_info = array()) { return p\Idn::idn_to_utf8($domain, $options, $variant, $idna_info); }
}
}

View File

@ -1,19 +0,0 @@
Copyright (c) 2015-2019 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
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:
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.

View File

@ -1,847 +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.
*/
namespace Symfony\Polyfill\Mbstring;
/**
* Partial mbstring implementation in PHP, iconv based, UTF-8 centric.
*
* Implemented:
* - mb_chr - Returns a specific character from its Unicode code point
* - mb_convert_encoding - Convert character encoding
* - mb_convert_variables - Convert character code in variable(s)
* - mb_decode_mimeheader - Decode string in MIME header field
* - mb_encode_mimeheader - Encode string for MIME header XXX NATIVE IMPLEMENTATION IS REALLY BUGGED
* - mb_decode_numericentity - Decode HTML numeric string reference to character
* - mb_encode_numericentity - Encode character to HTML numeric string reference
* - mb_convert_case - Perform case folding on a string
* - mb_detect_encoding - Detect character encoding
* - mb_get_info - Get internal settings of mbstring
* - mb_http_input - Detect HTTP input character encoding
* - mb_http_output - Set/Get HTTP output character encoding
* - mb_internal_encoding - Set/Get internal character encoding
* - mb_list_encodings - Returns an array of all supported encodings
* - mb_ord - Returns the Unicode code point of a character
* - mb_output_handler - Callback function converts character encoding in output buffer
* - mb_scrub - Replaces ill-formed byte sequences with substitute characters
* - mb_strlen - Get string length
* - mb_strpos - Find position of first occurrence of string in a string
* - mb_strrpos - Find position of last occurrence of a string in a string
* - mb_str_split - Convert a string to an array
* - mb_strtolower - Make a string lowercase
* - mb_strtoupper - Make a string uppercase
* - mb_substitute_character - Set/Get substitution character
* - mb_substr - Get part of string
* - mb_stripos - Finds position of first occurrence of a string within another, case insensitive
* - mb_stristr - Finds first occurrence of a string within another, case insensitive
* - mb_strrchr - Finds the last occurrence of a character in a string within another
* - mb_strrichr - Finds the last occurrence of a character in a string within another, case insensitive
* - mb_strripos - Finds position of last occurrence of a string within another, case insensitive
* - mb_strstr - Finds first occurrence of a string within another
* - mb_strwidth - Return width of string
* - mb_substr_count - Count the number of substring occurrences
*
* Not implemented:
* - mb_convert_kana - Convert "kana" one from another ("zen-kaku", "han-kaku" and more)
* - mb_ereg_* - Regular expression with multibyte support
* - mb_parse_str - Parse GET/POST/COOKIE data and set global variable
* - mb_preferred_mime_name - Get MIME charset string
* - mb_regex_encoding - Returns current encoding for multibyte regex as string
* - mb_regex_set_options - Set/Get the default options for mbregex functions
* - mb_send_mail - Send encoded mail
* - mb_split - Split multibyte string using regular expression
* - mb_strcut - Get part of string
* - mb_strimwidth - Get truncated string with specified width
*
* @author Nicolas Grekas <p@tchwork.com>
*
* @internal
*/
final class Mbstring
{
const MB_CASE_FOLD = PHP_INT_MAX;
private static $encodingList = array('ASCII', 'UTF-8');
private static $language = 'neutral';
private static $internalEncoding = 'UTF-8';
private static $caseFold = array(
array('µ', 'ſ', "\xCD\x85", 'ς', "\xCF\x90", "\xCF\x91", "\xCF\x95", "\xCF\x96", "\xCF\xB0", "\xCF\xB1", "\xCF\xB5", "\xE1\xBA\x9B", "\xE1\xBE\xBE"),
array('μ', 's', 'ι', 'σ', 'β', 'θ', 'φ', 'π', 'κ', 'ρ', 'ε', "\xE1\xB9\xA1", 'ι'),
);
public static function mb_convert_encoding($s, $toEncoding, $fromEncoding = null)
{
if (\is_array($fromEncoding) || false !== strpos($fromEncoding, ',')) {
$fromEncoding = self::mb_detect_encoding($s, $fromEncoding);
} else {
$fromEncoding = self::getEncoding($fromEncoding);
}
$toEncoding = self::getEncoding($toEncoding);
if ('BASE64' === $fromEncoding) {
$s = base64_decode($s);
$fromEncoding = $toEncoding;
}
if ('BASE64' === $toEncoding) {
return base64_encode($s);
}
if ('HTML-ENTITIES' === $toEncoding || 'HTML' === $toEncoding) {
if ('HTML-ENTITIES' === $fromEncoding || 'HTML' === $fromEncoding) {
$fromEncoding = 'Windows-1252';
}
if ('UTF-8' !== $fromEncoding) {
$s = iconv($fromEncoding, 'UTF-8//IGNORE', $s);
}
return preg_replace_callback('/[\x80-\xFF]+/', array(__CLASS__, 'html_encoding_callback'), $s);
}
if ('HTML-ENTITIES' === $fromEncoding) {
$s = html_entity_decode($s, ENT_COMPAT, 'UTF-8');
$fromEncoding = 'UTF-8';
}
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)
{
$vars = array(&$a, &$b, &$c, &$d, &$e, &$f);
$ok = true;
array_walk_recursive($vars, function (&$v) use (&$ok, $toEncoding, $fromEncoding) {
if (false === $v = Mbstring::mb_convert_encoding($v, $toEncoding, $fromEncoding)) {
$ok = false;
}
});
return $ok ? $fromEncoding : false;
}
public static function mb_decode_mimeheader($s)
{
return iconv_mime_decode($s, 2, self::$internalEncoding);
}
public static function mb_encode_mimeheader($s, $charset = null, $transferEncoding = null, $linefeed = null, $indent = null)
{
trigger_error('mb_encode_mimeheader() is bugged. Please use iconv_mime_encode() instead', E_USER_WARNING);
}
public static function mb_decode_numericentity($s, $convmap, $encoding = null)
{
if (null !== $s && !\is_scalar($s) && !(\is_object($s) && \method_exists($s, '__toString'))) {
trigger_error('mb_decode_numericentity() expects parameter 1 to be string, '.\gettype($s).' given', E_USER_WARNING);
return null;
}
if (!\is_array($convmap) || !$convmap) {
return false;
}
if (null !== $encoding && !\is_scalar($encoding)) {
trigger_error('mb_decode_numericentity() expects parameter 3 to be string, '.\gettype($s).' given', E_USER_WARNING);
return ''; // Instead of null (cf. mb_encode_numericentity).
}
$s = (string) $s;
if ('' === $s) {
return '';
}
$encoding = self::getEncoding($encoding);
if ('UTF-8' === $encoding) {
$encoding = null;
if (!preg_match('//u', $s)) {
$s = @iconv('UTF-8', 'UTF-8//IGNORE', $s);
}
} else {
$s = iconv($encoding, 'UTF-8//IGNORE', $s);
}
$cnt = floor(\count($convmap) / 4) * 4;
for ($i = 0; $i < $cnt; $i += 4) {
// collector_decode_htmlnumericentity ignores $convmap[$i + 3]
$convmap[$i] += $convmap[$i + 2];
$convmap[$i + 1] += $convmap[$i + 2];
}
$s = preg_replace_callback('/&#(?:0*([0-9]+)|x0*([0-9a-fA-F]+))(?!&);?/', function (array $m) use ($cnt, $convmap) {
$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 Mbstring::mb_chr($c - $convmap[$i + 2]);
}
}
return $m[0];
}, $s);
if (null === $encoding) {
return $s;
}
return iconv('UTF-8', $encoding.'//IGNORE', $s);
}
public static function mb_encode_numericentity($s, $convmap, $encoding = null, $is_hex = false)
{
if (null !== $s && !\is_scalar($s) && !(\is_object($s) && \method_exists($s, '__toString'))) {
trigger_error('mb_encode_numericentity() expects parameter 1 to be string, '.\gettype($s).' given', E_USER_WARNING);
return null;
}
if (!\is_array($convmap) || !$convmap) {
return false;
}
if (null !== $encoding && !\is_scalar($encoding)) {
trigger_error('mb_encode_numericentity() expects parameter 3 to be string, '.\gettype($s).' given', E_USER_WARNING);
return null; // Instead of '' (cf. mb_decode_numericentity).
}
if (null !== $is_hex && !\is_scalar($is_hex)) {
trigger_error('mb_encode_numericentity() expects parameter 4 to be boolean, '.\gettype($s).' given', E_USER_WARNING);
return null;
}
$s = (string) $s;
if ('' === $s) {
return '';
}
$encoding = self::getEncoding($encoding);
if ('UTF-8' === $encoding) {
$encoding = null;
if (!preg_match('//u', $s)) {
$s = @iconv('UTF-8', 'UTF-8//IGNORE', $s);
}
} else {
$s = iconv($encoding, 'UTF-8//IGNORE', $s);
}
static $ulenMask = array("\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4);
$cnt = floor(\count($convmap) / 4) * 4;
$i = 0;
$len = \strlen($s);
$result = '';
while ($i < $len) {
$ulen = $s[$i] < "\x80" ? 1 : $ulenMask[$s[$i] & "\xF0"];
$uchr = substr($s, $i, $ulen);
$i += $ulen;
$c = self::mb_ord($uchr);
for ($j = 0; $j < $cnt; $j += 4) {
if ($c >= $convmap[$j] && $c <= $convmap[$j + 1]) {
$cOffset = ($c + $convmap[$j + 2]) & $convmap[$j + 3];
$result .= $is_hex ? sprintf('&#x%X;', $cOffset) : '&#'.$cOffset.';';
continue 2;
}
}
$result .= $uchr;
}
if (null === $encoding) {
return $result;
}
return iconv('UTF-8', $encoding.'//IGNORE', $result);
}
public static function mb_convert_case($s, $mode, $encoding = null)
{
$s = (string) $s;
if ('' === $s) {
return '';
}
$encoding = self::getEncoding($encoding);
if ('UTF-8' === $encoding) {
$encoding = null;
if (!preg_match('//u', $s)) {
$s = @iconv('UTF-8', 'UTF-8//IGNORE', $s);
}
} else {
$s = iconv($encoding, 'UTF-8//IGNORE', $s);
}
if (MB_CASE_TITLE == $mode) {
static $titleRegexp = null;
if (null === $titleRegexp) {
$titleRegexp = self::getData('titleCaseRegexp');
}
$s = preg_replace_callback($titleRegexp, array(__CLASS__, 'title_case'), $s);
} else {
if (MB_CASE_UPPER == $mode) {
static $upper = null;
if (null === $upper) {
$upper = self::getData('upperCase');
}
$map = $upper;
} else {
if (self::MB_CASE_FOLD === $mode) {
$s = str_replace(self::$caseFold[0], self::$caseFold[1], $s);
}
static $lower = null;
if (null === $lower) {
$lower = self::getData('lowerCase');
}
$map = $lower;
}
static $ulenMask = array("\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4);
$i = 0;
$len = \strlen($s);
while ($i < $len) {
$ulen = $s[$i] < "\x80" ? 1 : $ulenMask[$s[$i] & "\xF0"];
$uchr = substr($s, $i, $ulen);
$i += $ulen;
if (isset($map[$uchr])) {
$uchr = $map[$uchr];
$nlen = \strlen($uchr);
if ($nlen == $ulen) {
$nlen = $i;
do {
$s[--$nlen] = $uchr[--$ulen];
} while ($ulen);
} else {
$s = substr_replace($s, $uchr, $i - $ulen, $ulen);
$len += $nlen - $ulen;
$i += $nlen - $ulen;
}
}
}
}
if (null === $encoding) {
return $s;
}
return iconv('UTF-8', $encoding.'//IGNORE', $s);
}
public static function mb_internal_encoding($encoding = null)
{
if (null === $encoding) {
return self::$internalEncoding;
}
$encoding = self::getEncoding($encoding);
if ('UTF-8' === $encoding || false !== @iconv($encoding, $encoding, ' ')) {
self::$internalEncoding = $encoding;
return true;
}
return false;
}
public static function mb_language($lang = null)
{
if (null === $lang) {
return self::$language;
}
switch ($lang = strtolower($lang)) {
case 'uni':
case 'neutral':
self::$language = $lang;
return true;
}
return false;
}
public static function mb_list_encodings()
{
return array('UTF-8');
}
public static function mb_encoding_aliases($encoding)
{
switch (strtoupper($encoding)) {
case 'UTF8':
case 'UTF-8':
return array('utf8');
}
return false;
}
public static function mb_check_encoding($var = null, $encoding = 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);
}
public static function mb_detect_encoding($str, $encodingList = null, $strict = false)
{
if (null === $encodingList) {
$encodingList = self::$encodingList;
} else {
if (!\is_array($encodingList)) {
$encodingList = array_map('trim', explode(',', $encodingList));
}
$encodingList = array_map('strtoupper', $encodingList);
}
foreach ($encodingList as $enc) {
switch ($enc) {
case 'ASCII':
if (!preg_match('/[\x80-\xFF]/', $str)) {
return $enc;
}
break;
case 'UTF8':
case 'UTF-8':
if (preg_match('//u', $str)) {
return 'UTF-8';
}
break;
default:
if (0 === strncmp($enc, 'ISO-8859-', 9)) {
return $enc;
}
}
}
return false;
}
public static function mb_detect_order($encodingList = null)
{
if (null === $encodingList) {
return self::$encodingList;
}
if (!\is_array($encodingList)) {
$encodingList = array_map('trim', explode(',', $encodingList));
}
$encodingList = array_map('strtoupper', $encodingList);
foreach ($encodingList as $enc) {
switch ($enc) {
default:
if (strncmp($enc, 'ISO-8859-', 9)) {
return false;
}
// no break
case 'ASCII':
case 'UTF8':
case 'UTF-8':
}
}
self::$encodingList = $encodingList;
return true;
}
public static function mb_strlen($s, $encoding = null)
{
$encoding = self::getEncoding($encoding);
if ('CP850' === $encoding || 'ASCII' === $encoding) {
return \strlen($s);
}
return @iconv_strlen($s, $encoding);
}
public static function mb_strpos($haystack, $needle, $offset = 0, $encoding = null)
{
$encoding = self::getEncoding($encoding);
if ('CP850' === $encoding || 'ASCII' === $encoding) {
return strpos($haystack, $needle, $offset);
}
$needle = (string) $needle;
if ('' === $needle) {
trigger_error(__METHOD__.': Empty delimiter', E_USER_WARNING);
return false;
}
return iconv_strpos($haystack, $needle, $offset, $encoding);
}
public static function mb_strrpos($haystack, $needle, $offset = 0, $encoding = null)
{
$encoding = self::getEncoding($encoding);
if ('CP850' === $encoding || 'ASCII' === $encoding) {
return strrpos($haystack, $needle, $offset);
}
if ($offset != (int) $offset) {
$offset = 0;
} elseif ($offset = (int) $offset) {
if ($offset < 0) {
if (0 > $offset += self::mb_strlen($needle)) {
$haystack = self::mb_substr($haystack, 0, $offset, $encoding);
}
$offset = 0;
} else {
$haystack = self::mb_substr($haystack, $offset, 2147483647, $encoding);
}
}
$pos = iconv_strrpos($haystack, $needle, $encoding);
return false !== $pos ? $offset + $pos : false;
}
public static function mb_str_split($string, $split_length = 1, $encoding = null)
{
if (null !== $string && !\is_scalar($string) && !(\is_object($string) && \method_exists($string, '__toString'))) {
trigger_error('mb_str_split() expects parameter 1 to be string, '.\gettype($string).' given', E_USER_WARNING);
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 (null === $encoding) {
$encoding = mb_internal_encoding();
}
if ('UTF-8' === $encoding = self::getEncoding($encoding)) {
$rx = '/(';
while (65535 < $split_length) {
$rx .= '.{65535}';
$split_length -= 65535;
}
$rx .= '.{'.$split_length.'})/us';
return preg_split($rx, $string, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
}
$result = array();
$length = mb_strlen($string, $encoding);
for ($i = 0; $i < $length; $i += $split_length) {
$result[] = mb_substr($string, $i, $split_length, $encoding);
}
return $result;
}
public static function mb_strtolower($s, $encoding = null)
{
return self::mb_convert_case($s, MB_CASE_LOWER, $encoding);
}
public static function mb_strtoupper($s, $encoding = null)
{
return self::mb_convert_case($s, MB_CASE_UPPER, $encoding);
}
public static function mb_substitute_character($c = null)
{
if (0 === strcasecmp($c, 'none')) {
return true;
}
return null !== $c ? false : 'none';
}
public static function mb_substr($s, $start, $length = null, $encoding = null)
{
$encoding = self::getEncoding($encoding);
if ('CP850' === $encoding || 'ASCII' === $encoding) {
return (string) substr($s, $start, null === $length ? 2147483647 : $length);
}
if ($start < 0) {
$start = iconv_strlen($s, $encoding) + $start;
if ($start < 0) {
$start = 0;
}
}
if (null === $length) {
$length = 2147483647;
} elseif ($length < 0) {
$length = iconv_strlen($s, $encoding) + $length - $start;
if ($length < 0) {
return '';
}
}
return (string) iconv_substr($s, $start, $length, $encoding);
}
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);
return self::mb_strpos($haystack, $needle, $offset, $encoding);
}
public static function mb_stristr($haystack, $needle, $part = false, $encoding = null)
{
$pos = self::mb_stripos($haystack, $needle, 0, $encoding);
return self::getSubpart($pos, $part, $haystack, $encoding);
}
public static function mb_strrchr($haystack, $needle, $part = false, $encoding = null)
{
$encoding = self::getEncoding($encoding);
if ('CP850' === $encoding || 'ASCII' === $encoding) {
return strrchr($haystack, $needle, $part);
}
$needle = self::mb_substr($needle, 0, 1, $encoding);
$pos = iconv_strrpos($haystack, $needle, $encoding);
return self::getSubpart($pos, $part, $haystack, $encoding);
}
public static function mb_strrichr($haystack, $needle, $part = false, $encoding = null)
{
$needle = self::mb_substr($needle, 0, 1, $encoding);
$pos = self::mb_strripos($haystack, $needle, $encoding);
return self::getSubpart($pos, $part, $haystack, $encoding);
}
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);
return self::mb_strrpos($haystack, $needle, $offset, $encoding);
}
public static function mb_strstr($haystack, $needle, $part = false, $encoding = null)
{
$pos = strpos($haystack, $needle);
if (false === $pos) {
return false;
}
if ($part) {
return substr($haystack, 0, $pos);
}
return substr($haystack, $pos);
}
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',
);
if ('all' === $type) {
return $info;
}
if (isset($info[$type])) {
return $info[$type];
}
return false;
}
public static function mb_http_input($type = '')
{
return false;
}
public static function mb_http_output($encoding = null)
{
return null !== $encoding ? 'pass' === $encoding : 'pass';
}
public static function mb_strwidth($s, $encoding = null)
{
$encoding = self::getEncoding($encoding);
if ('UTF-8' !== $encoding) {
$s = iconv($encoding, 'UTF-8//IGNORE', $s);
}
$s = preg_replace('/[\x{1100}-\x{115F}\x{2329}\x{232A}\x{2E80}-\x{303E}\x{3040}-\x{A4CF}\x{AC00}-\x{D7A3}\x{F900}-\x{FAFF}\x{FE10}-\x{FE19}\x{FE30}-\x{FE6F}\x{FF00}-\x{FF60}\x{FFE0}-\x{FFE6}\x{20000}-\x{2FFFD}\x{30000}-\x{3FFFD}]/u', '', $s, -1, $wide);
return ($wide << 1) + iconv_strlen($s, 'UTF-8');
}
public static function mb_substr_count($haystack, $needle, $encoding = null)
{
return substr_count($haystack, $needle);
}
public static function mb_output_handler($contents, $status)
{
return $contents;
}
public static function mb_chr($code, $encoding = null)
{
if (0x80 > $code %= 0x200000) {
$s = \chr($code);
} elseif (0x800 > $code) {
$s = \chr(0xC0 | $code >> 6).\chr(0x80 | $code & 0x3F);
} elseif (0x10000 > $code) {
$s = \chr(0xE0 | $code >> 12).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
} else {
$s = \chr(0xF0 | $code >> 18).\chr(0x80 | $code >> 12 & 0x3F).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
}
if ('UTF-8' !== $encoding = self::getEncoding($encoding)) {
$s = mb_convert_encoding($s, $encoding, 'UTF-8');
}
return $s;
}
public static function mb_ord($s, $encoding = null)
{
if ('UTF-8' !== $encoding = self::getEncoding($encoding)) {
$s = mb_convert_encoding($s, 'UTF-8', $encoding);
}
if (1 === \strlen($s)) {
return \ord($s);
}
$code = ($s = unpack('C*', substr($s, 0, 4))) ? $s[1] : 0;
if (0xF0 <= $code) {
return (($code - 0xF0) << 18) + (($s[2] - 0x80) << 12) + (($s[3] - 0x80) << 6) + $s[4] - 0x80;
}
if (0xE0 <= $code) {
return (($code - 0xE0) << 12) + (($s[2] - 0x80) << 6) + $s[3] - 0x80;
}
if (0xC0 <= $code) {
return (($code - 0xC0) << 6) + $s[2] - 0x80;
}
return $code;
}
private static function getSubpart($pos, $part, $haystack, $encoding)
{
if (false === $pos) {
return false;
}
if ($part) {
return self::mb_substr($haystack, 0, $pos, $encoding);
}
return self::mb_substr($haystack, $pos, null, $encoding);
}
private static function html_encoding_callback(array $m)
{
$i = 1;
$entities = '';
$m = unpack('C*', htmlentities($m[0], ENT_COMPAT, 'UTF-8'));
while (isset($m[$i])) {
if (0x80 > $m[$i]) {
$entities .= \chr($m[$i++]);
continue;
}
if (0xF0 <= $m[$i]) {
$c = (($m[$i++] - 0xF0) << 18) + (($m[$i++] - 0x80) << 12) + (($m[$i++] - 0x80) << 6) + $m[$i++] - 0x80;
} elseif (0xE0 <= $m[$i]) {
$c = (($m[$i++] - 0xE0) << 12) + (($m[$i++] - 0x80) << 6) + $m[$i++] - 0x80;
} else {
$c = (($m[$i++] - 0xC0) << 6) + $m[$i++] - 0x80;
}
$entities .= '&#'.$c.';';
}
return $entities;
}
private static function title_case(array $s)
{
return self::mb_convert_case($s[1], MB_CASE_UPPER, 'UTF-8').self::mb_convert_case($s[2], MB_CASE_LOWER, 'UTF-8');
}
private static function getData($file)
{
if (file_exists($file = __DIR__.'/Resources/unidata/'.$file.'.php')) {
return require $file;
}
return false;
}
private static function getEncoding($encoding)
{
if (null === $encoding) {
return self::$internalEncoding;
}
if ('UTF-8' === $encoding) {
return 'UTF-8';
}
$encoding = strtoupper($encoding);
if ('8BIT' === $encoding || 'BINARY' === $encoding) {
return 'CP850';
}
if ('UTF8' === $encoding) {
return 'UTF-8';
}
return $encoding;
}
}

File diff suppressed because one or more lines are too long

View File

@ -1,64 +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 Symfony\Polyfill\Mbstring as p;
if (!defined('MB_CASE_UPPER')) {
define('MB_CASE_UPPER', 0);
define('MB_CASE_LOWER', 1);
define('MB_CASE_TITLE', 2);
}
if (!function_exists('mb_strlen')) {
function mb_convert_encoding($s, $to, $from = null) { return p\Mbstring::mb_convert_encoding($s, $to, $from); }
function mb_decode_mimeheader($s) { return p\Mbstring::mb_decode_mimeheader($s); }
function mb_encode_mimeheader($s, $charset = null, $transferEnc = null, $lf = null, $indent = null) { return p\Mbstring::mb_encode_mimeheader($s, $charset, $transferEnc, $lf, $indent); }
function mb_decode_numericentity($s, $convmap, $enc = null) { return p\Mbstring::mb_decode_numericentity($s, $convmap, $enc); }
function mb_encode_numericentity($s, $convmap, $enc = null, $is_hex = false) { return p\Mbstring::mb_encode_numericentity($s, $convmap, $enc, $is_hex); }
function mb_convert_case($s, $mode, $enc = null) { return p\Mbstring::mb_convert_case($s, $mode, $enc); }
function mb_internal_encoding($enc = null) { return p\Mbstring::mb_internal_encoding($enc); }
function mb_language($lang = null) { return p\Mbstring::mb_language($lang); }
function mb_list_encodings() { return p\Mbstring::mb_list_encodings(); }
function mb_encoding_aliases($encoding) { return p\Mbstring::mb_encoding_aliases($encoding); }
function mb_check_encoding($var = null, $encoding = null) { return p\Mbstring::mb_check_encoding($var, $encoding); }
function mb_detect_encoding($str, $encodingList = null, $strict = false) { return p\Mbstring::mb_detect_encoding($str, $encodingList, $strict); }
function mb_detect_order($encodingList = null) { return p\Mbstring::mb_detect_order($encodingList); }
function mb_parse_str($s, &$result = array()) { parse_str($s, $result); }
function mb_strlen($s, $enc = null) { return p\Mbstring::mb_strlen($s, $enc); }
function mb_strpos($s, $needle, $offset = 0, $enc = null) { return p\Mbstring::mb_strpos($s, $needle, $offset, $enc); }
function mb_strtolower($s, $enc = null) { return p\Mbstring::mb_strtolower($s, $enc); }
function mb_strtoupper($s, $enc = null) { return p\Mbstring::mb_strtoupper($s, $enc); }
function mb_substitute_character($char = null) { return p\Mbstring::mb_substitute_character($char); }
function mb_substr($s, $start, $length = 2147483647, $enc = null) { return p\Mbstring::mb_substr($s, $start, $length, $enc); }
function mb_stripos($s, $needle, $offset = 0, $enc = null) { return p\Mbstring::mb_stripos($s, $needle, $offset, $enc); }
function mb_stristr($s, $needle, $part = false, $enc = null) { return p\Mbstring::mb_stristr($s, $needle, $part, $enc); }
function mb_strrchr($s, $needle, $part = false, $enc = null) { return p\Mbstring::mb_strrchr($s, $needle, $part, $enc); }
function mb_strrichr($s, $needle, $part = false, $enc = null) { return p\Mbstring::mb_strrichr($s, $needle, $part, $enc); }
function mb_strripos($s, $needle, $offset = 0, $enc = null) { return p\Mbstring::mb_strripos($s, $needle, $offset, $enc); }
function mb_strrpos($s, $needle, $offset = 0, $enc = null) { return p\Mbstring::mb_strrpos($s, $needle, $offset, $enc); }
function mb_strstr($s, $needle, $part = false, $enc = null) { return p\Mbstring::mb_strstr($s, $needle, $part, $enc); }
function mb_get_info($type = 'all') { return p\Mbstring::mb_get_info($type); }
function mb_http_output($enc = null) { return p\Mbstring::mb_http_output($enc); }
function mb_strwidth($s, $enc = null) { return p\Mbstring::mb_strwidth($s, $enc); }
function mb_substr_count($haystack, $needle, $enc = null) { return p\Mbstring::mb_substr_count($haystack, $needle, $enc); }
function mb_output_handler($contents, $status) { return p\Mbstring::mb_output_handler($contents, $status); }
function mb_http_input($type = '') { return p\Mbstring::mb_http_input($type); }
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_chr')) {
function mb_ord($s, $enc = null) { return p\Mbstring::mb_ord($s, $enc); }
function mb_chr($code, $enc = null) { return p\Mbstring::mb_chr($code, $enc); }
function mb_scrub($s, $enc = null) { $enc = null === $enc ? mb_internal_encoding() : $enc; return mb_convert_encoding($s, $enc, $enc); }
}
if (!function_exists('mb_str_split')) {
function mb_str_split($string, $split_length = 1, $encoding = null) { return p\Mbstring::mb_str_split($string, $split_length, $encoding); }
}

View File

@ -1,19 +0,0 @@
Copyright (c) 2015-2019 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
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:
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.

View File

@ -1,216 +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.
*/
namespace Symfony\Polyfill\Php72;
/**
* @author Nicolas Grekas <p@tchwork.com>
* @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
*
* @internal
*/
final class Php72
{
private static $hashMask;
public static function utf8_encode($s)
{
$s .= $s;
$len = \strlen($s);
for ($i = $len >> 1, $j = 0; $i < $len; ++$i, ++$j) {
switch (true) {
case $s[$i] < "\x80": $s[$j] = $s[$i]; break;
case $s[$i] < "\xC0": $s[$j] = "\xC2"; $s[++$j] = $s[$i]; break;
default: $s[$j] = "\xC3"; $s[++$j] = \chr(\ord($s[$i]) - 64); break;
}
}
return substr($s, 0, $j);
}
public static function utf8_decode($s)
{
$s = (string) $s;
$len = \strlen($s);
for ($i = 0, $j = 0; $i < $len; ++$i, ++$j) {
switch ($s[$i] & "\xF0") {
case "\xC0":
case "\xD0":
$c = (\ord($s[$i] & "\x1F") << 6) | \ord($s[++$i] & "\x3F");
$s[$j] = $c < 256 ? \chr($c) : '?';
break;
case "\xF0":
++$i;
// no break
case "\xE0":
$s[$j] = '?';
$i += 2;
break;
default:
$s[$j] = $s[$i];
}
}
return substr($s, 0, $j);
}
public static function php_os_family()
{
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';
}
public static function spl_object_id($object)
{
if (null === self::$hashMask) {
self::initHashMask();
}
if (null === $hash = spl_object_hash($object)) {
return;
}
return self::$hashMask ^ hexdec(substr($hash, 16 - \PHP_INT_SIZE, \PHP_INT_SIZE));
}
public static function sapi_windows_vt100_support($stream, $enable = null)
{
if (!\is_resource($stream)) {
trigger_error('sapi_windows_vt100_support() expects parameter 1 to be resource, '.\gettype($stream).' given', E_USER_WARNING);
return false;
}
$meta = stream_get_meta_data($stream);
if ('STDIO' !== $meta['stream_type']) {
trigger_error('sapi_windows_vt100_support() was not able to analyze the specified stream', E_USER_WARNING);
return false;
}
// We cannot actually disable vt100 support if it is set
if (false === $enable || !self::stream_isatty($stream)) {
return false;
}
// The native function does not apply to stdin
$meta = array_map('strtolower', $meta);
$stdin = 'php://stdin' === $meta['uri'] || 'php://fd/0' === $meta['uri'];
return !$stdin
&& (false !== getenv('ANSICON')
|| 'ON' === getenv('ConEmuANSI')
|| 'xterm' === getenv('TERM')
|| 'Hyper' === getenv('TERM_PROGRAM'));
}
public static function stream_isatty($stream)
{
if (!\is_resource($stream)) {
trigger_error('stream_isatty() expects parameter 1 to be resource, '.\gettype($stream).' given', E_USER_WARNING);
return false;
}
if ('\\' === \DIRECTORY_SEPARATOR) {
$stat = @fstat($stream);
// Check if formatted mode is S_IFCHR
return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;
}
return \function_exists('posix_isatty') && @posix_isatty($stream);
}
private static function initHashMask()
{
$obj = (object) array();
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');
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;
break;
}
}
if (!empty($frame['line'])) {
ob_start();
debug_zval_dump($obj);
self::$hashMask = (int) substr(ob_get_clean(), 17);
}
self::$hashMask ^= hexdec(substr(spl_object_hash($obj), 16 - \PHP_INT_SIZE, \PHP_INT_SIZE));
}
public static function mb_chr($code, $encoding = null)
{
if (0x80 > $code %= 0x200000) {
$s = \chr($code);
} elseif (0x800 > $code) {
$s = \chr(0xC0 | $code >> 6).\chr(0x80 | $code & 0x3F);
} elseif (0x10000 > $code) {
$s = \chr(0xE0 | $code >> 12).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
} else {
$s = \chr(0xF0 | $code >> 18).\chr(0x80 | $code >> 12 & 0x3F).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
}
if ('UTF-8' !== $encoding) {
$s = mb_convert_encoding($s, $encoding, 'UTF-8');
}
return $s;
}
public static function mb_ord($s, $encoding = null)
{
if (null == $encoding) {
$s = mb_convert_encoding($s, 'UTF-8');
} elseif ('UTF-8' !== $encoding) {
$s = mb_convert_encoding($s, 'UTF-8', $encoding);
}
if (1 === \strlen($s)) {
return \ord($s);
}
$code = ($s = unpack('C*', substr($s, 0, 4))) ? $s[1] : 0;
if (0xF0 <= $code) {
return (($code - 0xF0) << 18) + (($s[2] - 0x80) << 12) + (($s[3] - 0x80) << 6) + $s[4] - 0x80;
}
if (0xE0 <= $code) {
return (($code - 0xE0) << 12) + (($s[2] - 0x80) << 6) + $s[3] - 0x80;
}
if (0xC0 <= $code) {
return (($code - 0xC0) << 6) + $s[2] - 0x80;
}
return $code;
}
}

View File

@ -1,36 +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 Symfony\Polyfill\Php72 as p;
if (PHP_VERSION_ID < 70200) {
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')) {
function stream_isatty($stream) { return p\Php72::stream_isatty($stream); }
}
if (!function_exists('utf8_encode')) {
function utf8_encode($s) { return p\Php72::utf8_encode($s); }
function utf8_decode($s) { return p\Php72::utf8_decode($s); }
}
if (!function_exists('spl_object_id')) {
function spl_object_id($s) { return p\Php72::spl_object_id($s); }
}
if (!defined('PHP_OS_FAMILY')) {
define('PHP_OS_FAMILY', p\Php72::php_os_family());
}
if (!function_exists('mb_chr')) {
function mb_ord($s, $enc = null) { return p\Php72::mb_ord($s, $enc); }
function mb_chr($code, $enc = null) { return p\Php72::mb_chr($code, $enc); }
function mb_scrub($s, $enc = null) { $enc = null === $enc ? mb_internal_encoding() : $enc; return mb_convert_encoding($s, $enc, $enc); }
}
}

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* Plugin Name: WP Mail SMTP * Plugin Name: WP Mail SMTP
* Version: 2.0.0 * Version: 2.0.1
* Plugin URI: https://wpmailsmtp.com/ * Plugin URI: https://wpmailsmtp.com/
* Description: Reconfigures the <code>wp_mail()</code> function to use Gmail/Mailgun/SendGrid/SMTP instead of the default <code>mail()</code> and creates an options page to manage the settings. * Description: Reconfigures the <code>wp_mail()</code> function to use Gmail/Mailgun/SendGrid/SMTP instead of the default <code>mail()</code> and creates an options page to manage the settings.
* Author: WPForms * Author: WPForms
@ -203,7 +203,7 @@ if ( ! function_exists( 'wp_mail_smtp_insecure_php_version_notice' ) ) {
} }
if ( ! defined( 'WPMS_PLUGIN_VER' ) ) { if ( ! defined( 'WPMS_PLUGIN_VER' ) ) {
define( 'WPMS_PLUGIN_VER', '2.0.0' ); define( 'WPMS_PLUGIN_VER', '2.0.1' );
} }
if ( ! defined( 'WPMS_PHP_VER' ) ) { if ( ! defined( 'WPMS_PHP_VER' ) ) {
define( 'WPMS_PHP_VER', '5.5.0' ); define( 'WPMS_PHP_VER', '5.5.0' );