idn_to_ascii is only used if available

This commit is contained in:
Thomas Müller 2014-03-26 11:17:23 +01:00
parent 75d8de378c
commit 83b4bcfdbf
2 changed files with 12 additions and 0 deletions

View File

@ -137,6 +137,9 @@ class OC_Mail {
* @return string
*/
public static function buildAsciiEmail($emailAddress) {
if (!function_exists('idn_to_ascii')) {
return $emailAddress;
}
list($name, $domain) = explode('@', $emailAddress, 2);
$domain = idn_to_ascii($domain);

View File

@ -8,6 +8,15 @@
class Test_Mail extends PHPUnit_Framework_TestCase {
protected function setUp()
{
if (!function_exists('idn_to_ascii')) {
$this->markTestSkipped(
'The intl extension is not available.'
);
}
}
/**
* @dataProvider buildAsciiEmailProvider
* @param $expected