mirror of
https://github.com/PHPMailer/PHPMailer.git
synced 2024-09-20 01:52:15 +02:00
PHPMailer::parseAddresses(): bug fix [1] - extension availability not checked
Follow up to #2266 Bug fix In both "arms" (imap vs native implementation) of the `PHPMailer::parseAddresses()` method, the `mb_decode_mimeheader()` function is used to decoded a (utf-8) encoded name. In the IMAP "arm", a check was in place for the Mbstring extension being available before using it. This check was missing from the "native implementation" "arm". Existing Tests This also means that both currently existing tests have a requirement for the MbString extension being available. This was previously not made explicit in the tests. Fixed now.
This commit is contained in:
parent
8fd56f335e
commit
8827c9b3ce
@ -1237,7 +1237,7 @@ class PHPMailer
|
||||
$name = trim($name);
|
||||
if (static::validateAddress($email)) {
|
||||
//If this name is encoded, decode it
|
||||
if (preg_match('/^=\?.*\?=$/', $name)) {
|
||||
if (extension_loaded('mbstring') && preg_match('/^=\?.*\?=$/', $name)) {
|
||||
$name = mb_decode_mimeheader($name);
|
||||
}
|
||||
$addresses[] = [
|
||||
|
@ -27,6 +27,8 @@ final class ParseAddressesTest extends TestCase
|
||||
/**
|
||||
* Test RFC822 address splitting using the PHPMailer native implementation.
|
||||
*
|
||||
* @requires extension mbstring
|
||||
*
|
||||
* @dataProvider dataAddressSplitting
|
||||
*
|
||||
* @param string $addrstr The address list string.
|
||||
@ -42,9 +44,10 @@ final class ParseAddressesTest extends TestCase
|
||||
/**
|
||||
* Test RFC822 address splitting using the IMAP implementation.
|
||||
*
|
||||
* @dataProvider dataAddressSplitting
|
||||
*
|
||||
* @requires extension imap
|
||||
* @requires extension mbstring
|
||||
*
|
||||
* @dataProvider dataAddressSplitting
|
||||
*
|
||||
* @param string $addrstr The address list string.
|
||||
* @param array $expected The expected function output.
|
||||
|
Loading…
Reference in New Issue
Block a user