Make WordPress Core

Changeset 49034


Ignore:
Timestamp:
09/22/2020 06:35:10 PM (5 years ago)
Author:
desrosj
Message:

External Libraries: Upgrade PHPMailer to version 6.1.7.

For a full list of changes in this update, see the PHPMailer GitHub: https://github.com/PHPMailer/PHPMailer/compare/v6.1.6...v6.1.7.

Props ayeshrajans, jrf.
Fixes #51311.

Location:
trunk/src/wp-includes/PHPMailer
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/PHPMailer/PHPMailer.php

    r48045 r49034  
    442442     *
    443443     * @var bool
     444     *
     445     * @deprecated 6.0.0 PHPMailer isn't a mailing list manager!
    444446     */
    445447    public $SingleTo = false;
     
    746748     * @var string
    747749     */
    748     const VERSION = '6.1.6';
     750    const VERSION = '6.1.7';
    749751
    750752    /**
     
    13081310        }
    13091311        if (is_callable($patternselect)) {
    1310             return $patternselect($address);
     1312            return call_user_func($patternselect, $address);
    13111313        }
    13121314        //Reject line breaks in addresses; it's valid RFC5322, but not RFC5321
     
    14021404                $errorcode = 0;
    14031405                if (defined('INTL_IDNA_VARIANT_UTS46')) {
    1404                     // phpcs:ignore PHPCompatibility.ParameterValues.NewIDNVariantDefault.NotSet
    14051406                    $punycode = idn_to_ascii($domain, $errorcode, INTL_IDNA_VARIANT_UTS46);
    14061407                } elseif (defined('INTL_IDNA_VARIANT_2003')) {
     
    29792980                $name = $filename;
    29802981            }
    2981 
    29822982            if (!$this->validateEncoding($encoding)) {
    29832983                throw new Exception($this->lang('encoding') . $encoding);
     
    39943994     * @param string        $basedir  Absolute path to a base directory to prepend to relative paths to images
    39953995     * @param bool|callable $advanced Whether to use the internal HTML to text converter
    3996      *                                or your own custom converter @return string $message The transformed message Body
     3996     *                                or your own custom converter
     3997     * @return string The transformed message body
    39973998     *
    39983999     * @throws Exception
     
    41184119    {
    41194120        if (is_callable($advanced)) {
    4120             return $advanced($html);
     4121            return call_user_func($advanced, $html);
    41214122        }
    41224123
  • trunk/src/wp-includes/PHPMailer/SMTP.php

    r48033 r49034  
    3535     * @var string
    3636     */
    37     const VERSION = '6.1.6';
     37    const VERSION = '6.1.7';
    3838
    3939    /**
     
    312312    public function connect($host, $port = null, $timeout = 30, $options = [])
    313313    {
    314         static $streamok;
    315         //This is enabled by default since 5.0.0 but some providers disable it
    316         //Check this once and cache the result
    317         if (null === $streamok) {
    318             $streamok = function_exists('stream_socket_client');
    319         }
    320314        // Clear errors to avoid confusion
    321315        $this->setError('');
     
    336330            self::DEBUG_CONNECTION
    337331        );
     332
     333        $this->smtp_conn = $this->getSMTPConnection($host, $port, $timeout, $options);
     334
     335        if ($this->smtp_conn === false) {
     336            //Error info already set inside `getSMTPConnection()`
     337            return false;
     338        }
     339
     340        $this->edebug('Connection: opened', self::DEBUG_CONNECTION);
     341
     342        // Get any announcement
     343        $this->last_reply = $this->get_lines();
     344        $this->edebug('SERVER -> CLIENT: ' . $this->last_reply, self::DEBUG_SERVER);
     345
     346        return true;
     347    }
     348
     349    /**
     350     * Create connection to the SMTP server.
     351     *
     352     * @param string $host    SMTP server IP or host name
     353     * @param int    $port    The port number to connect to
     354     * @param int    $timeout How long to wait for the connection to open
     355     * @param array  $options An array of options for stream_context_create()
     356     *
     357     * @return false|resource
     358     */
     359    protected function getSMTPConnection($host, $port = null, $timeout = 30, $options = [])
     360    {
     361        static $streamok;
     362        //This is enabled by default since 5.0.0 but some providers disable it
     363        //Check this once and cache the result
     364        if (null === $streamok) {
     365            $streamok = function_exists('stream_socket_client');
     366        }
     367
    338368        $errno = 0;
    339369        $errstr = '';
     
    341371            $socket_context = stream_context_create($options);
    342372            set_error_handler([$this, 'errorHandler']);
    343             $this->smtp_conn = stream_socket_client(
     373            $connection = stream_socket_client(
    344374                $host . ':' . $port,
    345375                $errno,
     
    357387            );
    358388            set_error_handler([$this, 'errorHandler']);
    359             $this->smtp_conn = fsockopen(
     389            $connection = fsockopen(
    360390                $host,
    361391                $port,
     
    366396            restore_error_handler();
    367397        }
     398
    368399        // Verify we connected properly
    369         if (!is_resource($this->smtp_conn)) {
     400        if (!is_resource($connection)) {
    370401            $this->setError(
    371402                'Failed to connect to server',
     
    382413            return false;
    383414        }
    384         $this->edebug('Connection: opened', self::DEBUG_CONNECTION);
     415
    385416        // SMTP server can take longer to respond, give longer timeout for first read
    386417        // Windows does not have support for this timeout function
    387418        if (strpos(PHP_OS, 'WIN') !== 0) {
    388             $max = (int) ini_get('max_execution_time');
     419            $max = (int)ini_get('max_execution_time');
    389420            // Don't bother if unlimited
    390421            if (0 !== $max && $timeout > $max) {
    391422                @set_time_limit($timeout);
    392423            }
    393             stream_set_timeout($this->smtp_conn, $timeout, 0);
    394         }
    395         // Get any announcement
    396         $announce = $this->get_lines();
    397         $this->edebug('SERVER -> CLIENT: ' . $announce, self::DEBUG_SERVER);
    398 
    399         return true;
     424            stream_set_timeout($connection, $timeout, 0);
     425        }
     426
     427        return $connection;
    400428    }
    401429
     
    11671195        while (is_resource($this->smtp_conn) && !feof($this->smtp_conn)) {
    11681196            //Must pass vars in here as params are by reference
    1169             if (!stream_select($selR, $selW, $selW, $this->Timelimit)) {
     1197            //solution for signals inspired by https://github.com/symfony/symfony/pull/6540
     1198            set_error_handler([$this, 'errorHandler']);
     1199            $n = stream_select($selR, $selW, $selW, $this->Timelimit);
     1200            restore_error_handler();
     1201
     1202            if ($n === false) {
     1203                $message = $this->getError()['detail'];
     1204
     1205                $this->edebug(
     1206                    'SMTP -> get_lines(): select failed (' . $message . ')',
     1207                    self::DEBUG_LOWLEVEL
     1208                );
     1209
     1210                //stream_select returns false when the `select` system call is interrupted by an incoming signal, try the select again
     1211                if (stripos($message, 'interrupted system call') !== false) {
     1212                    $this->edebug(
     1213                        'SMTP -> get_lines(): retrying stream_select',
     1214                        self::DEBUG_LOWLEVEL
     1215                    );
     1216                    $this->setError('');
     1217                    continue;
     1218                }
     1219
     1220                break;
     1221            }
     1222
     1223            if (!$n) {
    11701224                $this->edebug(
    11711225                    'SMTP -> get_lines(): select timed-out in (' . $this->Timelimit . ' sec)',
     
    11741228                break;
    11751229            }
     1230
    11761231            //Deliberate noise suppression - errors are handled afterwards
    11771232            $str = @fgets($this->smtp_conn, self::MAX_REPLY_LENGTH);
Note: See TracChangeset for help on using the changeset viewer.