A free, self-hostable news aggregator…
Update phpmailer/phpmailer requirement from 7.0.1 to 7.0.2 in /lib (#8483)
dependabot[bot]afa7c8440f33
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 3394ef6b5..ef93a8a73 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -18,6 +18,7 @@ See also [the FreshRSS releases](https://github.com/FreshRSS/FreshRSS/releases).* Improve Simplified Chinese [#8474](https://github.com/FreshRSS/FreshRSS/pull/8474), [#8475](https://github.com/FreshRSS/FreshRSS/pull/8475), [#8476](https://github.com/FreshRSS/FreshRSS/pull/8476)* Misc.* Initial conventions for AI agents and humans: `AGENTS.md`, `SKILLS.md`, `instructions.md` [#8478](https://github.com/FreshRSS/FreshRSS/pull/8478)+ * Update to PHPMailer 7.0.2 [#8483](https://github.com/FreshRSS/FreshRSS/pull/8483)* Update dev dependencies [#8469](https://github.com/FreshRSS/FreshRSS/pull/8469), [#8480](https://github.com/FreshRSS/FreshRSS/pull/8480)diff --git a/lib/composer.json b/lib/composer.jsonindex f8150277c..9b8a51126 100644--- a/lib/composer.json+++ b/lib/composer.json@@ -13,7 +13,7 @@"require": {"marienfressinaud/lib_opml": "0.5.1","phpgt/cssxpath": "v1.4.0",- "phpmailer/phpmailer": "7.0.1",+ "phpmailer/phpmailer": "7.0.2","simplepie/simplepie": "dev-freshrss#dbcf155c82a17872f0bf8562723cc809842064ee"},"config": {diff --git a/lib/phpmailer/phpmailer/VERSION b/lib/phpmailer/phpmailer/VERSIONindex 9fe9ff9d9..a8907c025 100644--- a/lib/phpmailer/phpmailer/VERSION+++ b/lib/phpmailer/phpmailer/VERSION@@ -1 +1 @@-7.0.1+7.0.2diff --git a/lib/phpmailer/phpmailer/src/PHPMailer.php b/lib/phpmailer/phpmailer/src/PHPMailer.phpindex eb48e8581..2bb3578c7 100644--- a/lib/phpmailer/phpmailer/src/PHPMailer.php+++ b/lib/phpmailer/phpmailer/src/PHPMailer.php@@ -768,7 +768,7 @@ class PHPMailer** @var string*/- const VERSION = '7.0.1';+ const VERSION = '7.0.2';/*** Error severity: message only, continue processing.@@ -988,6 +988,54 @@ class PHPMailer$this->Mailer = 'mail';}+ /**+ * Extract sendmail path and parse to deal with known parameters.+ *+ * @param string $sendmailPath The sendmail path as set in php.ini+ *+ * @return string The sendmail path without the known parameters+ */+ private function parseSendmailPath($sendmailPath)+ {+ $sendmailPath = trim((string)$sendmailPath);+ if ($sendmailPath === '') {+ return $sendmailPath;+ }++ $parts = preg_split('/\s+/', $sendmailPath);+ if (empty($parts)) {+ return $sendmailPath;+ }++ $command = array_shift($parts);+ $remainder = [];++ // Parse only -t, -i, -oi and -f parameters.+ for ($i = 0; $i < count($parts); ++$i) {+ $part = $parts[$i];+ if (preg_match('/^-(i|oi|t)$/', $part, $matches)) {+ continue;+ }+ if (preg_match('/^-f(.*)$/', $part, $matches)) {+ $address = $matches[1];+ if ($address === '' && isset($parts[$i + 1]) && strpos($parts[$i + 1], '-') !== 0) {+ $address = $parts[++$i];+ }+ $this->Sender = $address;+ continue;+ }++ $remainder[] = $part;+ }++ // The params that are not parsed are added back to the command.+ if (!empty($remainder)) {+ $command .= ' ' . implode(' ', $remainder);+ }++ return $command;+ }+/*** Send messages using $Sendmail.*/@@ -996,10 +1044,9 @@ class PHPMailer$ini_sendmail_path = ini_get('sendmail_path');if (false === stripos($ini_sendmail_path, 'sendmail')) {- $this->Sendmail = '/usr/sbin/sendmail';- } else {- $this->Sendmail = $ini_sendmail_path;+ $ini_sendmail_path = '/usr/sbin/sendmail';}+ $this->Sendmail = $this->parseSendmailPath($ini_sendmail_path);$this->Mailer = 'sendmail';}@@ -1011,10 +1058,9 @@ class PHPMailer$ini_sendmail_path = ini_get('sendmail_path');if (false === stripos($ini_sendmail_path, 'qmail')) {- $this->Sendmail = '/var/qmail/bin/qmail-inject';- } else {- $this->Sendmail = $ini_sendmail_path;+ $ini_sendmail_path = '/var/qmail/bin/qmail-inject';}+ $this->Sendmail = $this->parseSendmailPath($ini_sendmail_path);$this->Mailer = 'qmail';}@@ -1860,25 +1906,27 @@ class PHPMailer//PHP config has a sender address we can use$this->Sender = ini_get('sendmail_from');}- //CVE-2016-10033, CVE-2016-10045: Don't pass -f if characters will be escaped.++ $sendmailArgs = [];++ // CVE-2016-10033, CVE-2016-10045: Don't pass -f if characters will be escaped.+ // Also don't add the -f automatically unless it has been set either via Sender+ // or sendmail_path. Otherwise it can introduce new problems.+ // @see http://github.com/PHPMailer/PHPMailer/issues/2298if (!empty($this->Sender) && static::validateAddress($this->Sender) && self::isShellSafe($this->Sender)) {- if ($this->Mailer === 'qmail') {- $sendmailFmt = '%s -f%s';- } else {- $sendmailFmt = '%s -oi -f%s -t';- }- } elseif ($this->Mailer === 'qmail') {- $sendmailFmt = '%s';- } else {- //Allow sendmail to choose a default envelope sender. It may- //seem preferable to force it to use the From header as with- //SMTP, but that introduces new problems (see- //<https://github.com/PHPMailer/PHPMailer/issues/2298>), and- //it has historically worked this way.- $sendmailFmt = '%s -oi -t';+ $sendmailArgs[] = '-f' . $this->Sender;+ }++ // Qmail doesn't accept all the sendmail parameters+ // @see https://github.com/PHPMailer/PHPMailer/issues/3189+ if ($this->Mailer !== 'qmail') {+ $sendmailArgs[] = '-i';+ $sendmailArgs[] = '-t';}- $sendmail = sprintf($sendmailFmt, escapeshellcmd($this->Sendmail), $this->Sender);+ $resultArgs = (empty($sendmailArgs) ? '' : ' ' . implode(' ', $sendmailArgs));++ $sendmail = trim(escapeshellcmd($this->Sendmail) . $resultArgs);$this->edebug('Sendmail path: ' . $this->Sendmail);$this->edebug('Sendmail command: ' . $sendmail);$this->edebug('Envelope sender: ' . $this->Sender);@@ -2062,7 +2110,8 @@ class PHPMailer$this->Sender = ini_get('sendmail_from');}if (!empty($this->Sender) && static::validateAddress($this->Sender)) {- if (self::isShellSafe($this->Sender)) {+ $phpmailer_path = ini_get('sendmail_path');+ if (self::isShellSafe($this->Sender) && strpos($phpmailer_path, ' -f') === false) {$params = sprintf('-f%s', $this->Sender);}$old_from = ini_get('sendmail_from');diff --git a/lib/phpmailer/phpmailer/src/SMTP.php b/lib/phpmailer/phpmailer/src/SMTP.phpindex b657798c0..559b52c45 100644--- a/lib/phpmailer/phpmailer/src/SMTP.php+++ b/lib/phpmailer/phpmailer/src/SMTP.php@@ -36,7 +36,7 @@ class SMTP* @var string* @deprecated This constant will be removed in PHPMailer 8.0. Use `PHPMailer::VERSION` instead.*/- const VERSION = '7.0.1';+ const VERSION = '7.0.2';/*** SMTP line break constant.@@ -770,6 +770,25 @@ class SMTP}}+ private function iterateLines($s)+ {+ $start = 0;+ $length = strlen($s);++ for ($i = 0; $i < $length; $i++) {+ $c = $s[$i];+ if ($c === "\n" || $c === "\r") {+ yield substr($s, $start, $i - $start);+ if ($c === "\r" && $i + 1 < $length && $s[$i + 1] === "\n") {+ $i++;+ }+ $start = $i + 1;+ }+ }++ yield substr($s, $start);+ }+/*** Send an SMTP DATA command.* Issues a data command and sends the msg_data to the server,@@ -798,15 +817,16 @@ class SMTP* NOTE: this does not count towards line-length limit.*/- //Normalize line breaks before exploding- $lines = explode("\n", str_replace(["\r\n", "\r"], "\n", $msg_data));+ //Iterate over lines with normalized line breaks+ $lines = $this->iterateLines($msg_data);/* To distinguish between a complete RFC822 message and a plain message body, we check if the first field* of the first line (':' separated) does not contain a space then it _should_ be a header, and we will* process all lines before a blank line as headers.*/- $field = substr($lines[0], 0, strpos($lines[0], ':'));+ $first_line = $lines->current();+ $field = substr($first_line, 0, strpos($first_line, ':'));$in_headers = false;if (!empty($field) && strpos($field, ' ') === false) {$in_headers = true;