Skip to content

Commit

Permalink
[mms] IDN support no longer requires intl to be built-in to PHP.
Browse files Browse the repository at this point in the history
  • Loading branch information
slusarz committed Dec 20, 2014
1 parent f4f27bb commit 047bfb3
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 27 deletions.
11 changes: 4 additions & 7 deletions framework/Mail/lib/Horde/Mail/Rfc822/Address.php
Expand Up @@ -92,10 +92,8 @@ public function __set($name, $value)
{
switch ($name) {
case 'host':
$value = ltrim($value, '@');
$this->_host = function_exists('idn_to_utf8')
? strtolower(idn_to_utf8($value))
: strtolower($value);
$idna = new Net_IDNA2();
$this->_host = Horde_String::lower($idna->decode($value));
break;

case 'personal':
Expand Down Expand Up @@ -135,9 +133,8 @@ public function __get($name)
return $this->_host;

case 'host_idn':
return function_exists('idn_to_ascii')
? idn_to_ascii($this->_host)
: $this->host;
$idna = new Net_IDNA2();
return $idna->encode($this->_host);

case 'label':
return is_null($this->personal)
Expand Down
4 changes: 1 addition & 3 deletions framework/Mail/lib/Horde/Mail/Rfc822/Object.php
Expand Up @@ -42,9 +42,7 @@ public function __toString()
* If boolean true, encodes in 'UTF-8'.
* If a string, encodes using this charset.
* DEFAULT: false
* - idn: (boolean) If true, encodes IDN domain names
* (Punycode/RFC 3490).
* Requires the idn or intl PHP module.
* - idn: (boolean) If true, encodes IDN domain names (RFC 3490).
* DEFAULT: false
* - noquote: (boolean) If true, don't quote personal part. [@since
* 2.4.0]
Expand Down
11 changes: 9 additions & 2 deletions framework/Mail/package.xml
Expand Up @@ -21,7 +21,7 @@
</stability>
<license uri="http://www.horde.org/licenses/bsd">BSD-2-Clause</license>
<notes>
*
* [mms] IDN support no longer requires intl to be built-in to PHP.
</notes>
<contents>
<dir baseinstalldir="/" name="/">
Expand Down Expand Up @@ -132,6 +132,13 @@
<max>3.0.0alpha1</max>
<exclude>3.0.0alpha1</exclude>
</package>
<package>
<name>Net_IDNA2</name>
<channel>pear.php.net</channel>
<min>0.1.1</min>
<max>1.0.0alpha1</max>
<exclude>1.0.0alpha1</exclude>
</package>
</required>
<optional>
<package>
Expand Down Expand Up @@ -669,7 +676,7 @@
<date>2014-11-22</date>
<license uri="http://www.horde.org/licenses/bsd">BSD-2-Clause</license>
<notes>
*
* [mms] IDN support no longer requires intl to be built-in to PHP.
</notes>
</release>
</changelog>
Expand Down
7 changes: 0 additions & 7 deletions framework/Mail/test/Horde/Mail/ObjectTest.php
Expand Up @@ -93,10 +93,6 @@ public function testAddressConstructor()

public function testEncodedAddressWithIDNHost()
{
if (!extension_loaded('intl')) {
$this->markTestSkipped('Intl module is not available.');
}

$ob = new Horde_Mail_Rfc822_Address();
$ob->personal = 'Aäb';
$ob->mailbox = 'test';
Expand All @@ -110,9 +106,6 @@ public function testEncodedAddressWithIDNHost()

public function testDecodedAddressWithIDNHost()
{
if (!extension_loaded('intl')) {
$this->markTestSkipped('Intl module is not available.');
}
$ob = new Horde_Mail_Rfc822_Address();
$ob->personal = '=?utf-8?b?QcOkYg==?=';
$ob->mailbox = 'test';
Expand Down
6 changes: 1 addition & 5 deletions framework/Mail/test/Horde/Mail/ParseTest.php
Expand Up @@ -145,7 +145,7 @@ public function testGeneralParsing()
$this->assertInternalType('array', $result[0]->addresses[0]->comment);
$this->assertEquals($result[0]->addresses[0]->comment[0], 'A comment');
$this->assertEquals($result[0]->addresses[0]->mailbox, 'richard');
$this->assertEquals($result[0]->addresses[0]->host, 'localhost');
$this->assertEmpty($result[0]->addresses[0]->host);

$this->assertInternalType('object', $result[0]->addresses[1]);
$this->assertEquals($result[0]->addresses[1]->personal, '');
Expand Down Expand Up @@ -450,10 +450,6 @@ public function testParsingNonValidateAddressWithBareAddressAtFront()

public function testParsingIDNHost()
{
if (!extension_loaded('intl')) {
$this->markTestSkipped('Intl module is not available.');
}

$email = 'Aäb <test@üexample.com>';

$ob = $this->rfc822->parseAddressList($email);
Expand Down
3 changes: 0 additions & 3 deletions framework/Mail/test/Horde/Mail/SendTest.php
Expand Up @@ -49,9 +49,6 @@ public function testMixedEOLs()

public function testBug12116()
{
if (!extension_loaded('intl')) {
$this->markTestSkipped('Intl module is not available.');
}
$addr = new Horde_Mail_Rfc822_Address();
$addr->personal = 'Aäb';
$addr->mailbox = 'test';
Expand Down

0 comments on commit 047bfb3

Please sign in to comment.