Changeset 62975
- Timestamp:
- 08/03/2026 06:58:00 PM (6 weeks ago)
- Location:
- trunk/src/wp-includes/PHPMailer
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/PHPMailer/PHPMailer.php
r61468 r62975 60 60 const ICAL_METHOD_COUNTER = 'COUNTER'; 61 61 const ICAL_METHOD_DECLINECOUNTER = 'DECLINECOUNTER'; 62 const RFC822_DATE_FORMAT = 'D, j M Y H:i:s O'; 62 63 63 64 /** … … 78 79 79 80 /** 80 * The MIME Content- type of the message.81 * The MIME Content-Type of the message. 81 82 * 82 83 * @var string … … 160 161 161 162 /** 162 * Value-array of "method" in Content type header "text/calendar"163 * Value-array of "method" in Content-Type header "text/calendar" 163 164 * 164 165 * @var string[] … … 769 770 * @var string 770 771 */ 771 const VERSION = '7. 0.2';772 const VERSION = '7.1.1'; 772 773 773 774 /** … … 1284 1285 * Parse and validate a string containing one or more RFC822-style comma-separated email addresses 1285 1286 * of the form "display name <address>" into an array of name/address pairs. 1286 * Uses the imap_rfc822_parse_adrlist function if the IMAP extension is available. 1287 * Uses the imap_rfc822_parse_adrlist function if the IMAP extension is available and 1288 * the deprecated $useimap argument is truthy. 1287 1289 * Note that quotes in the name part are removed. 1288 1290 * … … 1290 1292 * 1291 1293 * @param string $addrstr The address list string 1292 * @param null $useimap Unused. Argument has been deprecated in PHPMailer 6.11.0.1293 * Previously this argument determined whether to use1294 * the IMAP extension to parse the list and accepted a boolean value.1294 * @param bool|null $useimap Deprecated in PHPMailer 6.11.0. 1295 * Truthy values request the deprecated IMAP parser 1296 * and trigger a deprecation warning. 1295 1297 * @param string $charset The charset to use when decoding the address list string. 1296 1298 * … … 1299 1301 public static function parseAddresses($addrstr, $useimap = null, $charset = self::CHARSET_ISO88591) 1300 1302 { 1301 if ($useimap !== null) {1303 if ($useimap == true) { 1302 1304 trigger_error(self::lang('deprecated_argument') . '$useimap', E_USER_DEPRECATED); 1303 1305 } 1304 1306 $addresses = []; 1305 if ( function_exists('imap_rfc822_parse_adrlist')) {1307 if ($useimap == true && function_exists('imap_rfc822_parse_adrlist')) { 1306 1308 //Use this built-in parser if it's available 1307 1309 // phpcs:ignore PHPCompatibility.FunctionUse.RemovedFunctions.imap_rfc822_parse_adrlistRemoved -- wrapped in function_exists() … … 1780 1782 //Trim subject consistently 1781 1783 $this->Subject = trim($this->Subject); 1784 1785 1782 1786 //Create body before headers in case body makes changes to headers (e.g. altering transfer encoding) 1783 1787 $this->MIMEHeader = ''; … … 1854 1858 default: 1855 1859 $sendMethod = $this->Mailer . 'Send'; 1856 if ( method_exists($this, $sendMethod)) {1860 if (!empty($this->Mailer) && method_exists($this, $sendMethod)) { 1857 1861 return $this->{$sendMethod}($this->MIMEHeader, $this->MIMEBody); 1858 1862 } … … 1912 1916 // CVE-2016-10033, CVE-2016-10045: Don't pass -f if characters will be escaped. 1913 1917 // Also don't add the -f automatically unless it has been set either via Sender 1914 // or sendmail_path. Otherwise it can introduce new problems.1918 // or sendmail_path. Otherwise, it can introduce new problems. 1915 1919 // @see http://github.com/PHPMailer/PHPMailer/issues/2298 1916 1920 if (!empty($this->Sender) && static::validateAddress($this->Sender) && self::isShellSafe($this->Sender)) { … … 2511 2515 'buggy_php' => 'Your version of PHP is affected by a bug that may result in corrupted messages.' . 2512 2516 ' To fix it, switch to sending using SMTP, disable the mail.add_x_header option in' . 2513 ' your php.ini, switch to MacOS or Linux, or upgrade your PHP to version 7.0.17+ or 7.1.3+.',2517 ' your php.ini, switch to macOS or Linux, or upgrade your PHP to version 7.0.17+ or 7.1.3+.', 2514 2518 'connect_host' => 'SMTP Error: Could not connect to SMTP host.', 2515 2519 'data_not_accepted' => 'SMTP Error: data not accepted.', … … 2848 2852 $result = ''; 2849 2853 2850 $result .= $this->headerLine('Date', '' === $this->MessageDate ? self::rfcDate() : $this->MessageDate); 2854 $result .= $this->headerLine( 2855 'Date', 2856 self::sanitiseDate($this->MessageDate) 2857 ); 2851 2858 2852 2859 //The To header is created automatically by mail(), so needs to be omitted here … … 2917 2924 } elseif (is_string($this->XMailer) && trim($this->XMailer) !== '') { 2918 2925 //Some string 2919 $result .= $this->headerLine('X-Mailer', trim($this->XMailer));2926 $result .= $this->headerLine('X-Mailer', $this->secureHeader(trim($this->XMailer))); 2920 2927 } //Other values result in no X-Mailer header 2921 2928 … … 2967 2974 default: 2968 2975 //Catches case 'plain': and case '': 2969 $result .= $this->textLine('Content-Type: ' . $this->ContentType . '; charset=' . $this->CharSet); 2976 $result .= $this->textLine( 2977 'Content-Type: ' . 2978 $this->secureHeader($this->ContentType) . 2979 '; charset=' . $this->secureHeader($this->CharSet) 2980 ); 2970 2981 $ismultipart = false; 2971 2982 break; 2972 2983 } 2984 if (!$this->validateEncoding($this->Encoding)) { 2985 throw new Exception(self::lang('encoding') . $this->Encoding); 2986 } 2973 2987 //RFC1341 part 5 says 7bit is assumed if not specified 2974 2988 if (static::ENCODING_7BIT !== $this->Encoding) { 2975 //RFC 2045 section 6.4 says multipart MIME parts may only use 7bit, 8bit or binary CTE2989 //RFC 2045 section 6.4 says multipart MIME parts may only use 7bit, 8bit, or binary CTE 2976 2990 if ($ismultipart) { 2977 2991 if (static::ENCODING_8BIT === $this->Encoding) { … … 3048 3062 $this->setWordWrap(); 3049 3063 3064 if (!$this->validateEncoding($this->Encoding)) { 3065 throw new Exception(self::lang('encoding') . $this->Encoding); 3066 } 3050 3067 $bodyEncoding = $this->Encoding; 3051 3068 $bodyCharSet = $this->CharSet; … … 4167 4184 { 4168 4185 return in_array( 4169 $encoding,4186 strtolower($encoding), 4170 4187 [ 4171 4188 self::ENCODING_7BIT, … … 4427 4444 4428 4445 /** 4429 * Return an RFC 822 formatted date.4446 * Return the current date and time as an RFC 822 formatted date. 4430 4447 * 4431 4448 * @return string … … 4437 4454 date_default_timezone_set(@date_default_timezone_get()); 4438 4455 4439 return date('D, j M Y H:i:s O'); 4456 return date(self::RFC822_DATE_FORMAT); 4457 } 4458 4459 /** 4460 * Normalise a user-supplied date into a correctly-formatted RFC 5322 date value 4461 * string suitable for use in the Date header. 4462 * 4463 * Accepts: 4464 * - A {@see \DateTime} (or \DateTimeImmutable) object 4465 * - Any date/time string understood by PHP's DateTime constructor (RFC 5322, ISO 8601, 4466 * Unix timestamp with leading "@", natural-language strings, etc.) 4467 * 4468 * Dates in the future are not permitted for email headers; if the parsed date is later 4469 * than "now" the method falls back to the current time via {@see self::rfcDate()}. 4470 * An empty value, a non-string/non-DateTime argument, or any value that cannot be 4471 * parsed will likewise fall back to {@see self::rfcDate()}. 4472 * 4473 * @param \DateTime|\DateTimeImmutable|string $date The date to normalise 4474 * 4475 * @return string An RFC 5322-formatted date string 4476 */ 4477 private static function sanitiseDate($date) 4478 { 4479 try { 4480 //Ensure the default timezone is set properly 4481 date_default_timezone_set(@date_default_timezone_get()); 4482 4483 if ($date instanceof \DateTimeInterface) { 4484 $dt = $date; 4485 } elseif (is_string($date) && $date !== '') { 4486 $dt = new \DateTime($date); 4487 } else { 4488 //Empty string, null, or any unsupported type 4489 return self::rfcDate(); 4490 } 4491 4492 //Reject future dates — they are invalid for outgoing message headers 4493 if ($dt->getTimestamp() > time()) { 4494 return self::rfcDate(); 4495 } 4496 4497 return $dt->format(self::RFC822_DATE_FORMAT); 4498 } catch (\Exception $e) { 4499 return self::rfcDate(); 4500 } 4440 4501 } 4441 4502 -
trunk/src/wp-includes/PHPMailer/POP3.php
r61468 r62975 48 48 * @deprecated This constant will be removed in PHPMailer 8.0. Use `PHPMailer::VERSION` instead. 49 49 */ 50 const VERSION = '7. 0.2';50 const VERSION = '7.1.1'; 51 51 52 52 /** … … 213 213 $this->tval = (int) $timeout; 214 214 } 215 $this->do_debug = $debug_level;216 $this->username = $username;217 $this->password = $password;215 $this->do_debug = (int) $debug_level; 216 $this->username = self::stripControls($username); 217 $this->password = self::stripControls($password); 218 218 //Reset the error log 219 219 $this->errors = []; … … 320 320 $password = $this->password; 321 321 } 322 322 $username = self::stripControls($username); 323 $password = self::stripControls($password); 323 324 //Send the Username 324 325 $this->sendString("USER $username" . static::LE); … … 408 409 /** 409 410 * Checks the POP3 server response. 410 * Looks for for+OK or -ERR.411 * Looks for +OK or -ERR. 411 412 * 412 413 * @param string $string … … 468 469 ); 469 470 } 471 472 /** 473 * Strip all control chars from a string. 474 * 475 * @param $string 476 * 477 * @return string 478 */ 479 protected static function stripControls($string) 480 { 481 return preg_replace('/[\x00-\x1F\x7F]/u', '', $string); 482 } 470 483 } -
trunk/src/wp-includes/PHPMailer/SMTP.php
r61468 r62975 37 37 * @deprecated This constant will be removed in PHPMailer 8.0. Use `PHPMailer::VERSION` instead. 38 38 */ 39 const VERSION = '7. 0.2';39 const VERSION = '7.1.1'; 40 40 41 41 /** … … 1290 1290 * $name == 'HELO'|'EHLO': returns the server name 1291 1291 * $name == any other string: if extension $name exists, returns True 1292 * or its options (e.g. AUTH mechanisms supported). Otherwise returns False.1292 * or its options (e.g. AUTH mechanisms supported). Otherwise, returns False. 1293 1293 * 1294 1294 * @param string $name Name of SMTP extension or 'HELO'|'EHLO'
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)