Fix #2563: Provide the right flags to IDN methods for email addresses conversion

This commit is contained in:
Julien BERNARD 2021-11-19 13:19:50 -05:00
parent e84b657160
commit 3c81f485df
2 changed files with 10 additions and 1 deletions

View File

@ -1451,7 +1451,11 @@ class PHPMailer
$errorcode = 0;
if (defined('INTL_IDNA_VARIANT_UTS46')) {
//Use the current punycode standard (appeared in PHP 7.2)
$punycode = idn_to_ascii($domain, $errorcode, \INTL_IDNA_VARIANT_UTS46);
$punycode = idn_to_ascii(
$domain,
\IDNA_DEFAULT | \IDNA_USE_STD3_RULES | \IDNA_CHECK_BIDI | \IDNA_CHECK_CONTEXTJ | \IDNA_NONTRANSITIONAL_TO_ASCII,
\INTL_IDNA_VARIANT_UTS46
);
} elseif (defined('INTL_IDNA_VARIANT_2003')) {
//Fall back to this old, deprecated/removed encoding
$punycode = idn_to_ascii($domain, $errorcode, \INTL_IDNA_VARIANT_2003);

View File

@ -72,6 +72,11 @@ final class PunyencodeAddressTest extends TestCase
'charset' => PHPMailer::CHARSET_UTF8,
'expected' => 'françois@xn--franois-xxa.ch',
],
'IDN conversion flags' => [
'input' => 'test@fußball.test',
'charset' => PHPMailer::CHARSET_UTF8,
'expected' => 'test@xn--fuball-cta.test',
],
];
}