Skip to content

Commit

Permalink
DEBUG step 2
Browse files Browse the repository at this point in the history
  • Loading branch information
jrfnl committed Sep 11, 2024
1 parent 2e359f4 commit 9d321f3
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/PHPMailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -1465,21 +1465,26 @@ public static function idnSupported()
*/
public function punyencodeAddress($address)
{
echo '==================================', PHP_EOL;
echo 'Received input: ', $address, PHP_EOL;
//Verify we have required functions, CharSet, and at-sign.
$pos = strrpos($address, '@');
if (
!empty($this->CharSet) &&
false !== $pos &&
static::idnSupported()
) {
echo __LINE__, ' - in if condition', PHP_EOL;
$domain = substr($address, ++$pos);
//Verify CharSet string is a valid one, and domain properly encoded in this CharSet.
if ($this->has8bitChars($domain) && @mb_check_encoding($domain, $this->CharSet)) {
echo __LINE__, ' - in second if condition', PHP_EOL;
//Convert the domain from whatever charset it's in to UTF-8
$domain = mb_convert_encoding($domain, self::CHARSET_UTF8, $this->CharSet);
//Ignore IDE complaints about this line - method signature changed in PHP 5.4
$errorcode = 0;
if (defined('INTL_IDNA_VARIANT_UTS46')) {
echo __LINE__, ' - in INTL_IDNA_VARIANT_UTS46 condition', PHP_EOL;
//Use the current punycode standard (appeared in PHP 7.2)
$punycode = idn_to_ascii(
$domain,
Expand All @@ -1488,18 +1493,22 @@ public function punyencodeAddress($address)
\INTL_IDNA_VARIANT_UTS46
);
} elseif (defined('INTL_IDNA_VARIANT_2003')) {
echo __LINE__, ' - in INTL_IDNA_VARIANT_2003 condition', PHP_EOL;
//Fall back to this old, deprecated/removed encoding
$punycode = idn_to_ascii($domain, $errorcode, \INTL_IDNA_VARIANT_2003);
} else {
echo __LINE__, ' - in fallback condition', PHP_EOL;
//Fall back to a default we don't know about
$punycode = idn_to_ascii($domain, $errorcode);
}
if (false !== $punycode) {
echo __LINE__, ' - returning based on punycode not false', PHP_EOL;
return substr($address, 0, $pos) . $punycode;
}
}
}

echo __LINE__, ' - fall back return', PHP_EOL;
return $address;
}

Expand Down

0 comments on commit 9d321f3

Please sign in to comment.