commit 2d5f609d0733785604d4447576edc11f3b39d08a
Author: Ayesh Karunaratne <ayesh@ayesh.me>
Date: Thu Nov 26 00:15:23 2020 +0700
PHPMailer 6.2.0
diff --git a/src/wp-includes/PHPMailer/Exception.php b/src/wp-includes/PHPMailer/Exception.php
index e7807fc2ca..a50a8991f7 100644
a
|
b
|
|
1 | 1 | <?php |
| 2 | |
2 | 3 | /** |
3 | 4 | * PHPMailer Exception class. |
4 | 5 | * PHP Version 5.5. |
diff --git a/src/wp-includes/PHPMailer/PHPMailer.php b/src/wp-includes/PHPMailer/PHPMailer.php
index 7e9f834bc8..31646b2a84 100644
a
|
b
|
|
1 | 1 | <?php |
| 2 | |
2 | 3 | /** |
3 | 4 | * PHPMailer - PHP email creation and transport class. |
4 | 5 | * PHP Version 5.5. |
… |
… |
class PHPMailer |
388 | 389 | * SMTP class debug output mode. |
389 | 390 | * Debug output level. |
390 | 391 | * Options: |
391 | | * * SMTP::DEBUG_OFF: No output |
392 | | * * SMTP::DEBUG_CLIENT: Client messages |
393 | | * * SMTP::DEBUG_SERVER: Client and server messages |
394 | | * * SMTP::DEBUG_CONNECTION: As SERVER plus connection status |
395 | | * * SMTP::DEBUG_LOWLEVEL: Noisy, low-level data output, rarely needed |
| 392 | * @see SMTP::DEBUG_OFF: No output |
| 393 | * @see SMTP::DEBUG_CLIENT: Client messages |
| 394 | * @see SMTP::DEBUG_SERVER: Client and server messages |
| 395 | * @see SMTP::DEBUG_CONNECTION: As SERVER plus connection status |
| 396 | * @see SMTP::DEBUG_LOWLEVEL: Noisy, low-level data output, rarely needed |
396 | 397 | * |
397 | 398 | * @see SMTP::$do_debug |
398 | 399 | * |
… |
… |
class PHPMailer |
747 | 748 | * |
748 | 749 | * @var string |
749 | 750 | */ |
750 | | const VERSION = '6.1.8'; |
| 751 | const VERSION = '6.2.0'; |
751 | 752 | |
752 | 753 | /** |
753 | 754 | * Error severity: message only, continue processing. |
… |
… |
public static function parseAddresses($addrstr, $useimap = true) |
1185 | 1186 | //Use this built-in parser if it's available |
1186 | 1187 | $list = imap_rfc822_parse_adrlist($addrstr, ''); |
1187 | 1188 | foreach ($list as $address) { |
1188 | | if (('.SYNTAX-ERROR.' !== $address->host) && static::validateAddress( |
1189 | | $address->mailbox . '@' . $address->host |
1190 | | )) { |
| 1189 | if ( |
| 1190 | ('.SYNTAX-ERROR.' !== $address->host) && static::validateAddress( |
| 1191 | $address->mailbox . '@' . $address->host |
| 1192 | ) |
| 1193 | ) { |
1191 | 1194 | $addresses[] = [ |
1192 | 1195 | 'name' => (property_exists($address, 'personal') ? $address->personal : ''), |
1193 | 1196 | 'address' => $address->mailbox . '@' . $address->host, |
… |
… |
public function setFrom($address, $name = '', $auto = true) |
1241 | 1244 | $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim |
1242 | 1245 | // Don't validate now addresses with IDN. Will be done in send(). |
1243 | 1246 | $pos = strrpos($address, '@'); |
1244 | | if ((false === $pos) |
| 1247 | if ( |
| 1248 | (false === $pos) |
1245 | 1249 | || ((!$this->has8bitChars(substr($address, ++$pos)) || !static::idnSupported()) |
1246 | 1250 | && !static::validateAddress($address)) |
1247 | 1251 | ) { |
… |
… |
public function punyencodeAddress($address) |
1393 | 1397 | { |
1394 | 1398 | // Verify we have required functions, CharSet, and at-sign. |
1395 | 1399 | $pos = strrpos($address, '@'); |
1396 | | if (!empty($this->CharSet) && |
| 1400 | if ( |
| 1401 | !empty($this->CharSet) && |
1397 | 1402 | false !== $pos && |
1398 | 1403 | static::idnSupported() |
1399 | 1404 | ) { |
… |
… |
public function send() |
1457 | 1462 | */ |
1458 | 1463 | public function preSend() |
1459 | 1464 | { |
1460 | | if ('smtp' === $this->Mailer |
1461 | | || ('mail' === $this->Mailer && stripos(PHP_OS, 'WIN') === 0) |
| 1465 | if ( |
| 1466 | 'smtp' === $this->Mailer |
| 1467 | || ('mail' === $this->Mailer && (PHP_VERSION_ID >= 80000 || stripos(PHP_OS, 'WIN') === 0)) |
1462 | 1468 | ) { |
1463 | 1469 | //SMTP mandates RFC-compliant line endings |
1464 | 1470 | //and it's also used with mail() on Windows |
… |
… |
public function preSend() |
1468 | 1474 | static::setLE(PHP_EOL); |
1469 | 1475 | } |
1470 | 1476 | //Check for buggy PHP versions that add a header with an incorrect line break |
1471 | | if ('mail' === $this->Mailer |
| 1477 | if ( |
| 1478 | 'mail' === $this->Mailer |
1472 | 1479 | && ((PHP_VERSION_ID >= 70000 && PHP_VERSION_ID < 70017) |
1473 | 1480 | || (PHP_VERSION_ID >= 70100 && PHP_VERSION_ID < 70103)) |
1474 | 1481 | && ini_get('mail.add_x_header') === '1' |
… |
… |
public function preSend() |
1555 | 1562 | } |
1556 | 1563 | |
1557 | 1564 | // Sign with DKIM if enabled |
1558 | | if (!empty($this->DKIM_domain) |
| 1565 | if ( |
| 1566 | !empty($this->DKIM_domain) |
1559 | 1567 | && !empty($this->DKIM_selector) |
1560 | 1568 | && (!empty($this->DKIM_private_string) |
1561 | 1569 | || (!empty($this->DKIM_private) |
… |
… |
public function postSend() |
1613 | 1621 | } |
1614 | 1622 | } catch (Exception $exc) { |
1615 | 1623 | if ($this->Mailer === 'smtp' && $this->SMTPKeepAlive == true) { |
1616 | | $this->smtp->reset(); |
| 1624 | $this->smtp->reset(); |
1617 | 1625 | } |
1618 | 1626 | $this->setError($exc->getMessage()); |
1619 | 1627 | $this->edebug($exc->getMessage()); |
… |
… |
protected function sendmailSend($header, $body) |
1719 | 1727 | protected static function isShellSafe($string) |
1720 | 1728 | { |
1721 | 1729 | // Future-proof |
1722 | | if (escapeshellcmd($string) !== $string |
| 1730 | if ( |
| 1731 | escapeshellcmd($string) !== $string |
1723 | 1732 | || !in_array(escapeshellarg($string), ["'$string'", "\"$string\""]) |
1724 | 1733 | ) { |
1725 | 1734 | return false; |
… |
… |
protected function smtpSend($header, $body) |
1903 | 1912 | $isSent = true; |
1904 | 1913 | } |
1905 | 1914 | |
1906 | | $callbacks[] = ['issent'=>$isSent, 'to'=>$to[0]]; |
| 1915 | $callbacks[] = ['issent' => $isSent, 'to' => $to[0]]; |
1907 | 1916 | } |
1908 | 1917 | } |
1909 | 1918 | |
… |
… |
public function smtpConnect($options = null) |
1983 | 1992 | |
1984 | 1993 | foreach ($hosts as $hostentry) { |
1985 | 1994 | $hostinfo = []; |
1986 | | if (!preg_match( |
1987 | | '/^(?:(ssl|tls):\/\/)?(.+?)(?::(\d+))?$/', |
1988 | | trim($hostentry), |
1989 | | $hostinfo |
1990 | | )) { |
| 1995 | if ( |
| 1996 | !preg_match( |
| 1997 | '/^(?:(ssl|tls):\/\/)?(.+?)(?::(\d+))?$/', |
| 1998 | trim($hostentry), |
| 1999 | $hostinfo |
| 2000 | ) |
| 2001 | ) { |
1991 | 2002 | $this->edebug($this->lang('invalid_hostentry') . ' ' . trim($hostentry)); |
1992 | 2003 | // Not a valid host entry |
1993 | 2004 | continue; |
… |
… |
public function smtpConnect($options = null) |
2056 | 2067 | // We must resend EHLO after TLS negotiation |
2057 | 2068 | $this->smtp->hello($hello); |
2058 | 2069 | } |
2059 | | if ($this->SMTPAuth && !$this->smtp->authenticate( |
2060 | | $this->Username, |
2061 | | $this->Password, |
2062 | | $this->AuthType, |
2063 | | $this->oauth |
2064 | | )) { |
| 2070 | if ( |
| 2071 | $this->SMTPAuth && !$this->smtp->authenticate( |
| 2072 | $this->Username, |
| 2073 | $this->Password, |
| 2074 | $this->AuthType, |
| 2075 | $this->oauth |
| 2076 | ) |
| 2077 | ) { |
2065 | 2078 | throw new Exception($this->lang('authenticate')); |
2066 | 2079 | } |
2067 | 2080 | |
… |
… |
public function setLanguage($langcode = 'en', $lang_path = '') |
2119 | 2132 | 'am' => 'hy', |
2120 | 2133 | ]; |
2121 | 2134 | |
2122 | | if (isset($renamed_langcodes[$langcode])) { |
| 2135 | if (array_key_exists($langcode, $renamed_langcodes)) { |
2123 | 2136 | $langcode = $renamed_langcodes[$langcode]; |
2124 | 2137 | } |
2125 | 2138 | |
… |
… |
public function createHeader() |
2428 | 2441 | } |
2429 | 2442 | |
2430 | 2443 | // sendmail and mail() extract Bcc from the header before sending |
2431 | | if (( |
| 2444 | if ( |
| 2445 | ( |
2432 | 2446 | 'sendmail' === $this->Mailer || 'qmail' === $this->Mailer || 'mail' === $this->Mailer |
2433 | 2447 | ) |
2434 | 2448 | && count($this->bcc) > 0 |
… |
… |
protected function serverHostname() |
3898 | 3912 | public static function isValidHost($host) |
3899 | 3913 | { |
3900 | 3914 | //Simple syntax limits |
3901 | | if (empty($host) |
| 3915 | if ( |
| 3916 | empty($host) |
3902 | 3917 | || !is_string($host) |
3903 | 3918 | || strlen($host) > 256 |
3904 | 3919 | || !preg_match('/^([a-zA-Z\d.-]*|\[[a-fA-F\d:]+])$/', $host) |
… |
… |
public function msgHTML($message, $basedir = '', $advanced = false) |
4064 | 4079 | ); |
4065 | 4080 | continue; |
4066 | 4081 | } |
4067 | | if (// Only process relative URLs if a basedir is provided (i.e. no absolute local paths) |
| 4082 | if ( |
| 4083 | // Only process relative URLs if a basedir is provided (i.e. no absolute local paths) |
4068 | 4084 | !empty($basedir) |
4069 | 4085 | // Ignore URLs containing parent dir traversal (..) |
4070 | 4086 | && (strpos($url, '..') === false) |
… |
… |
public function msgHTML($message, $basedir = '', $advanced = false) |
4086 | 4102 | if (strlen($directory) > 1 && '/' !== substr($directory, -1)) { |
4087 | 4103 | $directory .= '/'; |
4088 | 4104 | } |
4089 | | if ($this->addEmbeddedImage( |
4090 | | $basedir . $directory . $filename, |
4091 | | $cid, |
4092 | | $filename, |
4093 | | static::ENCODING_BASE64, |
4094 | | static::_mime_types((string) static::mb_pathinfo($filename, PATHINFO_EXTENSION)) |
4095 | | ) |
| 4105 | if ( |
| 4106 | $this->addEmbeddedImage( |
| 4107 | $basedir . $directory . $filename, |
| 4108 | $cid, |
| 4109 | $filename, |
| 4110 | static::ENCODING_BASE64, |
| 4111 | static::_mime_types((string) static::mb_pathinfo($filename, PATHINFO_EXTENSION)) |
| 4112 | ) |
4096 | 4113 | ) { |
4097 | 4114 | $message = preg_replace( |
4098 | 4115 | '/' . $images[1][$imgindex] . '=["\']' . preg_quote($url, '/') . '["\']/Ui', |
… |
… |
public function DKIM_Sign($signHeader) |
4511 | 4528 | $privKey = openssl_pkey_get_private($privKeyStr); |
4512 | 4529 | } |
4513 | 4530 | if (openssl_sign($signHeader, $signature, $privKey, 'sha256WithRSAEncryption')) { |
4514 | | openssl_pkey_free($privKey); |
| 4531 | if (PHP_MAJOR_VERSION < 8) { |
| 4532 | openssl_pkey_free($privKey); |
| 4533 | } |
4515 | 4534 | |
4516 | 4535 | return base64_encode($signature); |
4517 | 4536 | } |
4518 | | openssl_pkey_free($privKey); |
| 4537 | if (PHP_MAJOR_VERSION < 8) { |
| 4538 | openssl_pkey_free($privKey); |
| 4539 | } |
4519 | 4540 | |
4520 | 4541 | return ''; |
4521 | 4542 | } |
diff --git a/src/wp-includes/PHPMailer/SMTP.php b/src/wp-includes/PHPMailer/SMTP.php
index 9e43dce2a5..ab7f46e4c8 100644
a
|
b
|
|
1 | 1 | <?php |
| 2 | |
2 | 3 | /** |
3 | 4 | * PHPMailer RFC821 SMTP email transport class. |
4 | 5 | * PHP Version 5.5. |
… |
… |
class SMTP |
34 | 35 | * |
35 | 36 | * @var string |
36 | 37 | */ |
37 | | const VERSION = '6.1.8'; |
| 38 | const VERSION = '6.2.0'; |
38 | 39 | |
39 | 40 | /** |
40 | 41 | * SMTP line break constant. |
… |
… |
public function authenticate( |
539 | 540 | return false; |
540 | 541 | } |
541 | 542 | // Send encoded username and password |
542 | | if (!$this->sendCommand( |
543 | | 'User & Password', |
544 | | base64_encode("\0" . $username . "\0" . $password), |
545 | | 235 |
546 | | ) |
| 543 | if ( |
| 544 | !$this->sendCommand( |
| 545 | 'User & Password', |
| 546 | base64_encode("\0" . $username . "\0" . $password), |
| 547 | 235 |
| 548 | ) |
547 | 549 | ) { |
548 | 550 | return false; |
549 | 551 | } |
… |
… |
public function client_send($data, $command = '') |
1086 | 1088 | { |
1087 | 1089 | //If SMTP transcripts are left enabled, or debug output is posted online |
1088 | 1090 | //it can leak credentials, so hide credentials in all but lowest level |
1089 | | if (self::DEBUG_LOWLEVEL > $this->do_debug && |
1090 | | in_array($command, ['User & Password', 'Username', 'Password'], true)) { |
| 1091 | if ( |
| 1092 | self::DEBUG_LOWLEVEL > $this->do_debug && |
| 1093 | in_array($command, ['User & Password', 'Username', 'Password'], true) |
| 1094 | ) { |
1091 | 1095 | $this->edebug('CLIENT -> SERVER: [credentials hidden]', self::DEBUG_CLIENT); |
1092 | 1096 | } else { |
1093 | 1097 | $this->edebug('CLIENT -> SERVER: ' . $data, self::DEBUG_CLIENT); |
… |
… |
protected function get_lines() |
1207 | 1211 | self::DEBUG_LOWLEVEL |
1208 | 1212 | ); |
1209 | 1213 | |
1210 | | //stream_select returns false when the `select` system call is interrupted by an incoming signal, try the select again |
| 1214 | //stream_select returns false when the `select` system call is interrupted |
| 1215 | //by an incoming signal, try the select again |
1211 | 1216 | if (stripos($message, 'interrupted system call') !== false) { |
1212 | 1217 | $this->edebug( |
1213 | 1218 | 'SMTP -> get_lines(): retrying stream_select', |