|
|
|
@ -911,9 +911,13 @@ class rcube_utils
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Wrapper for idn_to_ascii with support for e-mail address
|
|
|
|
|
* Wrapper for idn_to_ascii with support for e-mail address.
|
|
|
|
|
*
|
|
|
|
|
* Warning: Domain names may be lowercase'd.
|
|
|
|
|
* Warning: An empty string may be returned on invalid domain.
|
|
|
|
|
*
|
|
|
|
|
* @param string $str Decoded e-mail address
|
|
|
|
|
*
|
|
|
|
|
* @return string Encoded e-mail address
|
|
|
|
|
*/
|
|
|
|
|
public static function idn_to_ascii($str)
|
|
|
|
@ -925,6 +929,7 @@ class rcube_utils
|
|
|
|
|
* Wrapper for idn_to_utf8 with support for e-mail address
|
|
|
|
|
*
|
|
|
|
|
* @param string $str Decoded e-mail address
|
|
|
|
|
*
|
|
|
|
|
* @return string Encoded e-mail address
|
|
|
|
|
*/
|
|
|
|
|
public static function idn_to_utf8($str)
|
|
|
|
@ -932,12 +937,12 @@ class rcube_utils
|
|
|
|
|
return self::idn_convert($str, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Convert a string to ascii or utf8
|
|
|
|
|
* Convert a string to ascii or utf8 (using IDNA standard)
|
|
|
|
|
*
|
|
|
|
|
* @param string $input Decoded e-mail address
|
|
|
|
|
* @param boolean $is_utf Convert by idn_to_ascii if true and idn_to_utf8 if false
|
|
|
|
|
*
|
|
|
|
|
* @return string Encoded e-mail address
|
|
|
|
|
*/
|
|
|
|
|
public static function idn_convert($input, $is_utf = false)
|
|
|
|
@ -954,12 +959,18 @@ class rcube_utils
|
|
|
|
|
// Note that in PHP 7.2/7.3 calling idn_to_* functions with default arguments
|
|
|
|
|
// throws a warning, so we have to set the variant explicitely (#6075)
|
|
|
|
|
$variant = defined('INTL_IDNA_VARIANT_UTS46') ? INTL_IDNA_VARIANT_UTS46 : null;
|
|
|
|
|
$options = 0;
|
|
|
|
|
$options = IDNA_DEFAULT;
|
|
|
|
|
|
|
|
|
|
// Because php-intl extension lowercases domains and return false
|
|
|
|
|
// on invalid input (#6224), we skip conversion when not needed
|
|
|
|
|
// for compatibility with our Net_IDNA2 wrappers in bootstrap.php
|
|
|
|
|
|
|
|
|
|
if ($is_utf) {
|
|
|
|
|
if (preg_match('/[^\x20-\x7E]/', $domain)) {
|
|
|
|
|
$domain = idn_to_ascii($domain, $options, $variant);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
}
|
|
|
|
|
else if (preg_match('/(^|\.)xn--/i', $domain)) {
|
|
|
|
|
$domain = idn_to_utf8($domain, $options, $variant);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|