From 10341cc3106916a218c4fc3394f674adf127d625 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20B?= Date: Sat, 14 Oct 2017 08:22:54 +0200 Subject: [PATCH] Make idnSupported() static (#1203) Upgrade guide and changelog say that idnSupported() is now static, but it actually isn't. Probably this PR should wait v6.1 or other version where breaking changes are OK. --- src/PHPMailer.php | 8 ++++---- test/PHPMailerTest.php | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/PHPMailer.php b/src/PHPMailer.php index 478fae912..7641cd66a 100644 --- a/src/PHPMailer.php +++ b/src/PHPMailer.php @@ -973,7 +973,7 @@ protected function addOrEnqueueAnAddress($kind, $address, $name) } $params = [$kind, $address, $name]; // Enqueue addresses with IDN until we know the PHPMailer::$CharSet. - if ($this->has8bitChars(substr($address, ++$pos)) and $this->idnSupported()) { + if ($this->has8bitChars(substr($address, ++$pos)) and static::idnSupported()) { if ('Reply-To' != $kind) { if (!array_key_exists($address, $this->RecipientsQueue)) { $this->RecipientsQueue[$address] = $params; @@ -1124,7 +1124,7 @@ public function setFrom($address, $name = '', $auto = true) // Don't validate now addresses with IDN. Will be done in send(). $pos = strrpos($address, '@'); if (false === $pos or - (!$this->has8bitChars(substr($address, ++$pos)) or !$this->idnSupported()) and + (!$this->has8bitChars(substr($address, ++$pos)) or !static::idnSupported()) and !static::validateAddress($address)) { $error_message = $this->lang('invalid_address') . " (setFrom) $address"; $this->setError($error_message); @@ -1249,7 +1249,7 @@ public static function validateAddress($address, $patternselect = null) * * @return bool `true` if required functions for IDN support are present */ - public function idnSupported() + public static function idnSupported() { return function_exists('idn_to_ascii') and function_exists('mb_convert_encoding'); } @@ -1272,7 +1272,7 @@ public function punyencodeAddress($address) { // Verify we have required functions, CharSet, and at-sign. $pos = strrpos($address, '@'); - if ($this->idnSupported() and + if (static::idnSupported() and !empty($this->CharSet) and false !== $pos ) { diff --git a/test/PHPMailerTest.php b/test/PHPMailerTest.php index 12a55b1a3..919be93bc 100644 --- a/test/PHPMailerTest.php +++ b/test/PHPMailerTest.php @@ -2192,7 +2192,7 @@ public function testConfirmReadingTo() ); $this->Mail->ConfirmReadingTo = 'test@françois.ch'; //Address with IDN - if ($this->Mail->idnSupported()) { + if (PHPMailer::idnSupported()) { $this->assertTrue($this->Mail->send(), $this->Mail->ErrorInfo); $this->assertEquals( 'test@xn--franois-xxa.ch', @@ -2209,7 +2209,7 @@ public function testConfirmReadingTo() */ public function testConvertEncoding() { - if (!$this->Mail->idnSupported()) { + if (!PHPMailer::idnSupported()) { $this->markTestSkipped('intl and/or mbstring extensions are not available'); } @@ -2260,7 +2260,7 @@ public function testConvertEncoding() */ public function testDuplicateIDNRemoved() { - if (!$this->Mail->idnSupported()) { + if (!PHPMailer::idnSupported()) { $this->markTestSkipped('intl and/or mbstring extensions are not available'); }