Upgrade PHPMailer from 5.2.10 to 5.2.14.

The full list of changes is available here: https://github.com/PHPMailer/PHPMailer/compare/v5.2.10...v5.2.14

Merge of [36083] to the 4.4 branch.

Fixes #35212.


Built from https://develop.svn.wordpress.org/branches/4.4@36131


git-svn-id: http://core.svn.wordpress.org/branches/4.4@36097 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Gary Pendergast 2015-12-31 03:32:22 +00:00
parent 715dba65bc
commit 39875a50f3
3 changed files with 417 additions and 195 deletions

File diff suppressed because it is too large Load Diff

View File

@ -28,25 +28,25 @@ class SMTP
{ {
/** /**
* The PHPMailer SMTP version number. * The PHPMailer SMTP version number.
* @type string * @var string
*/ */
const VERSION = '5.2.10'; const VERSION = '5.2.14';
/** /**
* SMTP line break constant. * SMTP line break constant.
* @type string * @var string
*/ */
const CRLF = "\r\n"; const CRLF = "\r\n";
/** /**
* The SMTP port to use if one is not specified. * The SMTP port to use if one is not specified.
* @type integer * @var integer
*/ */
const DEFAULT_SMTP_PORT = 25; const DEFAULT_SMTP_PORT = 25;
/** /**
* The maximum line length allowed by RFC 2822 section 2.1.1 * The maximum line length allowed by RFC 2822 section 2.1.1
* @type integer * @var integer
*/ */
const MAX_LINE_LENGTH = 998; const MAX_LINE_LENGTH = 998;
@ -77,15 +77,15 @@ class SMTP
/** /**
* The PHPMailer SMTP Version number. * The PHPMailer SMTP Version number.
* @type string * @var string
* @deprecated Use the `VERSION` constant instead * @deprecated Use the `VERSION` constant instead
* @see SMTP::VERSION * @see SMTP::VERSION
*/ */
public $Version = '5.2.10'; public $Version = '5.2.14';
/** /**
* SMTP server port number. * SMTP server port number.
* @type integer * @var integer
* @deprecated This is only ever used as a default value, so use the `DEFAULT_SMTP_PORT` constant instead * @deprecated This is only ever used as a default value, so use the `DEFAULT_SMTP_PORT` constant instead
* @see SMTP::DEFAULT_SMTP_PORT * @see SMTP::DEFAULT_SMTP_PORT
*/ */
@ -93,7 +93,7 @@ class SMTP
/** /**
* SMTP reply line ending. * SMTP reply line ending.
* @type string * @var string
* @deprecated Use the `CRLF` constant instead * @deprecated Use the `CRLF` constant instead
* @see SMTP::CRLF * @see SMTP::CRLF
*/ */
@ -107,7 +107,7 @@ class SMTP
* * self::DEBUG_SERVER (`2`) Client commands and server responses * * self::DEBUG_SERVER (`2`) Client commands and server responses
* * self::DEBUG_CONNECTION (`3`) As DEBUG_SERVER plus connection status * * self::DEBUG_CONNECTION (`3`) As DEBUG_SERVER plus connection status
* * self::DEBUG_LOWLEVEL (`4`) Low-level data output, all messages * * self::DEBUG_LOWLEVEL (`4`) Low-level data output, all messages
* @type integer * @var integer
*/ */
public $do_debug = self::DEBUG_OFF; public $do_debug = self::DEBUG_OFF;
@ -122,7 +122,7 @@ class SMTP
* <code> * <code>
* $smtp->Debugoutput = function($str, $level) {echo "debug level $level; message: $str";}; * $smtp->Debugoutput = function($str, $level) {echo "debug level $level; message: $str";};
* </code> * </code>
* @type string|callable * @var string|callable
*/ */
public $Debugoutput = 'echo'; public $Debugoutput = 'echo';
@ -130,7 +130,7 @@ class SMTP
* Whether to use VERP. * Whether to use VERP.
* @link http://en.wikipedia.org/wiki/Variable_envelope_return_path * @link http://en.wikipedia.org/wiki/Variable_envelope_return_path
* @link http://www.postfix.org/VERP_README.html Info on VERP * @link http://www.postfix.org/VERP_README.html Info on VERP
* @type boolean * @var boolean
*/ */
public $do_verp = false; public $do_verp = false;
@ -139,26 +139,26 @@ class SMTP
* Default of 5 minutes (300sec) is from RFC2821 section 4.5.3.2 * Default of 5 minutes (300sec) is from RFC2821 section 4.5.3.2
* This needs to be quite high to function correctly with hosts using greetdelay as an anti-spam measure. * This needs to be quite high to function correctly with hosts using greetdelay as an anti-spam measure.
* @link http://tools.ietf.org/html/rfc2821#section-4.5.3.2 * @link http://tools.ietf.org/html/rfc2821#section-4.5.3.2
* @type integer * @var integer
*/ */
public $Timeout = 300; public $Timeout = 300;
/** /**
* How long to wait for commands to complete, in seconds. * How long to wait for commands to complete, in seconds.
* Default of 5 minutes (300sec) is from RFC2821 section 4.5.3.2 * Default of 5 minutes (300sec) is from RFC2821 section 4.5.3.2
* @type integer * @var integer
*/ */
public $Timelimit = 300; public $Timelimit = 300;
/** /**
* The socket for the server connection. * The socket for the server connection.
* @type resource * @var resource
*/ */
protected $smtp_conn; protected $smtp_conn;
/** /**
* Error information, if any, for the last SMTP command. * Error information, if any, for the last SMTP command.
* @type array * @var array
*/ */
protected $error = array( protected $error = array(
'error' => '', 'error' => '',
@ -170,7 +170,7 @@ class SMTP
/** /**
* The reply the server sent to us for HELO. * The reply the server sent to us for HELO.
* If null, no HELO string has yet been received. * If null, no HELO string has yet been received.
* @type string|null * @var string|null
*/ */
protected $helo_rply = null; protected $helo_rply = null;
@ -181,13 +181,13 @@ class SMTP
* represents the server name. In case of HELO it is the only element of the array. * represents the server name. In case of HELO it is the only element of the array.
* Other values can be boolean TRUE or an array containing extension options. * Other values can be boolean TRUE or an array containing extension options.
* If null, no HELO/EHLO string has yet been received. * If null, no HELO/EHLO string has yet been received.
* @type array|null * @var array|null
*/ */
protected $server_caps = null; protected $server_caps = null;
/** /**
* The most recent reply received from the server. * The most recent reply received from the server.
* @type string * @var string
*/ */
protected $last_reply = ''; protected $last_reply = '';
@ -351,20 +351,21 @@ class SMTP
* Perform SMTP authentication. * Perform SMTP authentication.
* Must be run after hello(). * Must be run after hello().
* @see hello() * @see hello()
* @param string $username The user name * @param string $username The user name
* @param string $password The password * @param string $password The password
* @param string $authtype The auth type (PLAIN, LOGIN, NTLM, CRAM-MD5) * @param string $authtype The auth type (PLAIN, LOGIN, NTLM, CRAM-MD5, XOAUTH2)
* @param string $realm The auth realm for NTLM * @param string $realm The auth realm for NTLM
* @param string $workstation The auth workstation for NTLM * @param string $workstation The auth workstation for NTLM
* @access public * @param null|OAuth $OAuth An optional OAuth instance (@see PHPMailerOAuth)
* @return boolean True if successfully authenticated. * @return bool True if successfully authenticated.* @access public
*/ */
public function authenticate( public function authenticate(
$username, $username,
$password, $password,
$authtype = null, $authtype = null,
$realm = '', $realm = '',
$workstation = '' $workstation = '',
$OAuth = null
) { ) {
if (!$this->server_caps) { if (!$this->server_caps) {
$this->setError('Authentication is not allowed before HELO/EHLO'); $this->setError('Authentication is not allowed before HELO/EHLO');
@ -673,9 +674,11 @@ class SMTP
{ {
$this->server_caps = array(); $this->server_caps = array();
$lines = explode("\n", $this->last_reply); $lines = explode("\n", $this->last_reply);
foreach ($lines as $n => $s) { foreach ($lines as $n => $s) {
//First 4 chars contain response code followed by - or space
$s = trim(substr($s, 4)); $s = trim(substr($s, 4));
if (!$s) { if (empty($s)) {
continue; continue;
} }
$fields = explode(' ', $s); $fields = explode(' ', $s);
@ -685,11 +688,20 @@ class SMTP
$fields = $fields[0]; $fields = $fields[0];
} else { } else {
$name = array_shift($fields); $name = array_shift($fields);
if ($name == 'SIZE') { switch ($name) {
$fields = ($fields) ? $fields[0] : 0; case 'SIZE':
$fields = ($fields ? $fields[0] : 0);
break;
case 'AUTH':
if (!is_array($fields)) {
$fields = array();
}
break;
default:
$fields = true;
} }
} }
$this->server_caps[$name] = ($fields ? $fields : true); $this->server_caps[$name] = $fields;
} }
} }
} }
@ -739,15 +751,15 @@ class SMTP
* Sets the TO argument to $toaddr. * Sets the TO argument to $toaddr.
* Returns true if the recipient was accepted false if it was rejected. * Returns true if the recipient was accepted false if it was rejected.
* Implements from rfc 821: RCPT <SP> TO:<forward-path> <CRLF> * Implements from rfc 821: RCPT <SP> TO:<forward-path> <CRLF>
* @param string $toaddr The address the message is being sent to * @param string $address The address the message is being sent to
* @access public * @access public
* @return boolean * @return boolean
*/ */
public function recipient($toaddr) public function recipient($address)
{ {
return $this->sendCommand( return $this->sendCommand(
'RCPT TO', 'RCPT TO',
'RCPT TO:<' . $toaddr . '>', 'RCPT TO:<' . $address . '>',
array(250, 251) array(250, 251)
); );
} }
@ -766,9 +778,9 @@ class SMTP
/** /**
* Send a command to an SMTP server and check its return code. * Send a command to an SMTP server and check its return code.
* @param string $command The command name - not sent to the server * @param string $command The command name - not sent to the server
* @param string $commandstring The actual command to send * @param string $commandstring The actual command to send
* @param integer|array $expect One or more expected integer success codes * @param integer|array $expect One or more expected integer success codes
* @access protected * @access protected
* @return boolean True on success. * @return boolean True on success.
*/ */
@ -778,6 +790,11 @@ class SMTP
$this->setError("Called $command without being connected"); $this->setError("Called $command without being connected");
return false; return false;
} }
//Reject line breaks in all commands
if (strpos($commandstring, "\n") !== false or strpos($commandstring, "\r") !== false) {
$this->setError("Command '$command' contained line breaks");
return false;
}
$this->client_send($commandstring . self::CRLF); $this->client_send($commandstring . self::CRLF);
$this->last_reply = $this->get_lines(); $this->last_reply = $this->get_lines();
@ -981,10 +998,9 @@ class SMTP
} }
while (is_resource($this->smtp_conn) && !feof($this->smtp_conn)) { while (is_resource($this->smtp_conn) && !feof($this->smtp_conn)) {
$str = @fgets($this->smtp_conn, 515); $str = @fgets($this->smtp_conn, 515);
$this->edebug("SMTP -> get_lines(): \$data was \"$data\"", self::DEBUG_LOWLEVEL);
$this->edebug("SMTP -> get_lines(): \$str is \"$str\"", self::DEBUG_LOWLEVEL);
$data .= $str;
$this->edebug("SMTP -> get_lines(): \$data is \"$data\"", self::DEBUG_LOWLEVEL); $this->edebug("SMTP -> get_lines(): \$data is \"$data\"", self::DEBUG_LOWLEVEL);
$this->edebug("SMTP -> get_lines(): \$str is \"$str\"", self::DEBUG_LOWLEVEL);
$data .= $str;
// If 4th character is a space, we are done reading, break the loop, micro-optimisation over strlen // If 4th character is a space, we are done reading, break the loop, micro-optimisation over strlen
if ((isset($str[3]) and $str[3] == ' ')) { if ((isset($str[3]) and $str[3] == ' ')) {
break; break;

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.4.1-alpha-36129'; $wp_version = '4.4.1-alpha-36131';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.