Ticket #40472: 40472v2.diff
File 40472v2.diff, 10.2 KB (added by , 8 years ago) |
---|
-
src/wp-includes/class-phpmailer.php
31 31 * The PHPMailer Version number. 32 32 * @var string 33 33 */ 34 public $Version = '5.2.2 2';34 public $Version = '5.2.24'; 35 35 36 36 /** 37 37 * Email priority. … … 440 440 * 441 441 * Parameters: 442 442 * boolean $result result of the send action 443 * string $to email address of the recipient444 * string$cc cc email addresses445 * string$bcc bcc email addresses443 * array $to email addresses of the recipients 444 * array $cc cc email addresses 445 * array $bcc bcc email addresses 446 446 * string $subject the subject 447 447 * string $body the email body 448 448 * string $from email address of sender … … 1623 1623 1624 1624 foreach ($hosts as $hostentry) { 1625 1625 $hostinfo = array(); 1626 if (!preg_match('/^((ssl|tls):\/\/)*([a-zA-Z0-9\.-]*):?([0-9]*)$/', trim($hostentry), $hostinfo)) { 1626 if (!preg_match( 1627 '/^((ssl|tls):\/\/)*([a-zA-Z0-9\.-]*|\[[a-fA-F0-9:]+\]):?([0-9]*)$/', 1628 trim($hostentry), 1629 $hostinfo 1630 )) { 1627 1631 // Not a valid host entry 1632 $this->edebug('Ignoring invalid host: ' . $hostentry); 1628 1633 continue; 1629 1634 } 1630 1635 // $hostinfo[2]: optional ssl or tls prefix … … 1743 1748 'dk' => 'da', 1744 1749 'no' => 'nb', 1745 1750 'se' => 'sv', 1751 'sr' => 'rs' 1746 1752 ); 1747 1753 1748 1754 if (isset($renamed_langcodes[$langcode])) { … … 2025 2031 { 2026 2032 $result = ''; 2027 2033 2028 if ($this->MessageDate == '') { 2029 $this->MessageDate = self::rfcDate(); 2030 } 2031 $result .= $this->headerLine('Date', $this->MessageDate); 2034 $result .= $this->headerLine('Date', $this->MessageDate == '' ? self::rfcDate() : $this->MessageDate); 2032 2035 2033 2036 // To be created automatically by mail() 2034 2037 if ($this->SingleTo) { … … 4034 4037 */ 4035 4038 public function errorMessage() 4036 4039 { 4037 $errorMsg = '<strong>' . $this->getMessage() . "</strong><br />\n";4040 $errorMsg = '<strong>' . htmlspecialchars($this->getMessage()) . "</strong><br />\n"; 4038 4041 return $errorMsg; 4039 4042 } 4040 4043 } -
src/wp-includes/class-smtp.php
30 30 * The PHPMailer SMTP version number. 31 31 * @var string 32 32 */ 33 const VERSION = '5.2.2 2';33 const VERSION = '5.2.24'; 34 34 35 35 /** 36 36 * SMTP line break constant. … … 81 81 * @deprecated Use the `VERSION` constant instead 82 82 * @see SMTP::VERSION 83 83 */ 84 public $Version = '5.2.2 2';84 public $Version = '5.2.24'; 85 85 86 86 /** 87 87 * SMTP server port number. … … 227 227 break; 228 228 case 'html': 229 229 //Cleans up output a bit for a better looking, HTML-safe output 230 echo htmlentities(230 echo gmdate('Y-m-d H:i:s') . ' ' . htmlentities( 231 231 preg_replace('/[\r\n]+/', '', $str), 232 232 ENT_QUOTES, 233 233 'UTF-8' 234 ) 235 . "<br>\n"; 234 ) . "<br>\n"; 236 235 break; 237 236 case 'echo': 238 237 default: … … 242 241 "\n", 243 242 "\n \t ", 244 243 trim($str) 245 ) ."\n";244 ) . "\n"; 246 245 } 247 246 } 248 247 … … 276 275 } 277 276 // Connect to the SMTP server 278 277 $this->edebug( 279 "Connection: opening to $host:$port, timeout=$timeout, options=".var_export($options, true), 278 "Connection: opening to $host:$port, timeout=$timeout, options=" . 279 var_export($options, true), 280 280 self::DEBUG_CONNECTION 281 281 ); 282 282 $errno = 0; … … 362 362 } 363 363 364 364 // Begin encrypted connection 365 if (!stream_socket_enable_crypto( 365 set_error_handler(array($this, 'errorHandler')); 366 $crypto_ok = stream_socket_enable_crypto( 366 367 $this->smtp_conn, 367 368 true, 368 369 $crypto_method 369 )) { 370 return false; 371 } 372 return true; 370 ); 371 restore_error_handler(); 372 return $crypto_ok; 373 373 } 374 374 375 375 /** … … 398 398 } 399 399 400 400 if (array_key_exists('EHLO', $this->server_caps)) { 401 // SMTP extensions are available. Let's try to find a proper authentication method 402 401 // SMTP extensions are available; try to find a proper authentication method 403 402 if (!array_key_exists('AUTH', $this->server_caps)) { 404 403 $this->setError('Authentication is not allowed at this stage'); 405 404 // 'at this stage' means that auth may be allowed after the stage changes … … 424 423 $this->setError('No supported authentication methods found'); 425 424 return false; 426 425 } 427 self::edebug('Auth method selected: ' .$authtype, self::DEBUG_LOWLEVEL);426 self::edebug('Auth method selected: ' . $authtype, self::DEBUG_LOWLEVEL); 428 427 } 429 428 430 429 if (!in_array($authtype, $this->server_caps['AUTH'])) { … … 487 486 * Works like hash_hmac('md5', $data, $key) 488 487 * in case that function is not available 489 488 * @param string $data The data to hash 490 * @param string $key 489 * @param string $key The key to hash with 491 490 * @access protected 492 491 * @return string 493 492 */ … … 830 829 $code_ex = (count($matches) > 2 ? $matches[2] : null); 831 830 // Cut off error code from each response line 832 831 $detail = preg_replace( 833 "/{$code}[ -]".($code_ex ? str_replace('.', '\\.', $code_ex).' ' : '')."/m", 832 "/{$code}[ -]" . 833 ($code_ex ? str_replace('.', '\\.', $code_ex) . ' ' : '') . "/m", 834 834 '', 835 835 $this->last_reply 836 836 ); … … 926 926 public function client_send($data) 927 927 { 928 928 $this->edebug("CLIENT -> SERVER: $data", self::DEBUG_CLIENT); 929 return fwrite($this->smtp_conn, $data); 929 set_error_handler(array($this, 'errorHandler')); 930 $result = fwrite($this->smtp_conn, $data); 931 restore_error_handler(); 932 return $result; 930 933 } 931 934 932 935 /** … … 1026 1029 $this->edebug("SMTP -> get_lines(): \$data is \"$data\"", self::DEBUG_LOWLEVEL); 1027 1030 $this->edebug("SMTP -> get_lines(): \$str is \"$str\"", self::DEBUG_LOWLEVEL); 1028 1031 $data .= $str; 1029 // If 4th character is a space, we are done reading, break the loop, micro-optimisation over strlen 1030 if ((isset($str[3]) and $str[3] == ' ')) { 1032 // If response is only 3 chars (not valid, but RFC5321 S4.2 says it must be handled), 1033 // or 4th character is a space, we are done reading, break the loop, 1034 // string array access is a micro-optimisation over strlen 1035 if (!isset($str[3]) or (isset($str[3]) and $str[3] == ' ')) { 1031 1036 break; 1032 1037 } 1033 1038 // Timed-out? Log and break … … 1042 1047 // Now check if reads took too long 1043 1048 if ($endtime and time() > $endtime) { 1044 1049 $this->edebug( 1045 'SMTP -> get_lines(): timelimit reached (' .1050 'SMTP -> get_lines(): timelimit reached (' . 1046 1051 $this->Timelimit . ' sec)', 1047 1052 self::DEBUG_LOWLEVEL 1048 1053 ); … … 1145 1150 * Reports an error number and string. 1146 1151 * @param integer $errno The error number returned by PHP. 1147 1152 * @param string $errmsg The error message returned by PHP. 1153 * @param string $errfile The file the error occurred in 1154 * @param integer $errline The line number the error occurred on 1148 1155 */ 1149 protected function errorHandler($errno, $errmsg )1156 protected function errorHandler($errno, $errmsg, $errfile = '', $errline = 0) 1150 1157 { 1151 $notice = 'Connection : Failed to connect to server.';1158 $notice = 'Connection failed.'; 1152 1159 $this->setError( 1153 1160 $notice, 1154 1161 $errno, … … 1155 1162 $errmsg 1156 1163 ); 1157 1164 $this->edebug( 1158 $notice . ' Error number ' . $errno . '. "Error notice: ' . $errmsg,1165 $notice . ' Error #' . $errno . ': ' . $errmsg . " [$errfile line $errline]", 1159 1166 self::DEBUG_CONNECTION 1160 1167 ); 1161 1168 } 1162 1169 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1170 /** 1171 * Will return the ID of the last smtp transaction based on a list of patterns provided 1172 * in SMTP::$smtp_transaction_id_patterns. 1173 * If no reply has been received yet, it will return null. 1174 * If no pattern has been matched, it will return false. 1175 * @return bool|null|string 1176 */ 1177 public function getLastTransactionID() 1178 { 1179 $reply = $this->getLastReply(); 1173 1180 1174 1175 1176 1181 if (empty($reply)) { 1182 return null; 1183 } 1177 1184 1178 foreach($this->smtp_transaction_id_patterns as $smtp_transaction_id_pattern) {1179 if(preg_match($smtp_transaction_id_pattern, $reply, $matches)) {1180 1181 1182 1185 foreach ($this->smtp_transaction_id_patterns as $smtp_transaction_id_pattern) { 1186 if (preg_match($smtp_transaction_id_pattern, $reply, $matches)) { 1187 return $matches[1]; 1188 } 1189 } 1183 1190 1184 1191 return false; 1185 1192 } 1186 1193 }