Skip to content

Commit

Permalink
[mms] More thorough job trying to parse addresses that contain an @ b…
Browse files Browse the repository at this point in the history
…ut no domain information.
  • Loading branch information
slusarz committed Jan 21, 2014
1 parent d5a84d4 commit 505f50f
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 21 deletions.
12 changes: 9 additions & 3 deletions framework/Mail/lib/Horde/Mail/Rfc822.php
Expand Up @@ -394,9 +394,15 @@ protected function _parseAddrSpec()
$ob->mailbox = $this->_parseLocalPart();

if ($this->_curr() == '@') {
$this->_rfc822ParseDomain($host);
if (strlen($host)) {
$ob->host = $host;
try {
$this->_rfc822ParseDomain($host);
if (strlen($host)) {
$ob->host = $host;
}
} catch (Horde_Mail_Exception $e) {
if (!empty($this->_params['validate'])) {
throw $e;
}
}
}

Expand Down
4 changes: 2 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] More thorough job trying to parse addresses that contain an @ but no domain information.
</notes>
<contents>
<dir baseinstalldir="/" name="/">
Expand Down Expand Up @@ -536,7 +536,7 @@
<date>2014-01-17</date>
<license uri="http://www.horde.org/licenses/bsd">BSD-2-Clause</license>
<notes>
*
* [mms] More thorough job trying to parse addresses that contain an @ but no domain information.
</notes>
</release>
</changelog>
Expand Down
41 changes: 25 additions & 16 deletions framework/Mail/test/Horde/Mail/ParseTest.php
Expand Up @@ -554,27 +554,36 @@ public function testDefaultDomain()
);
}

public function testBareMailboxWithoutDefaultDomainWhenValidating()
public function testBareMailboxWithoutDefaultDomainWithoutValidating()
{
$address = 'foo';
$addresses = array('foo', 'foo@');

try {
$this->rfc822->parseAddressList($address, array(
'default_domain' => null,
'validate' => true
foreach ($addresses as $val) {
$res = $this->rfc822->parseAddressList($val, array(
'default_domain' => null
));
$this->fail('An expected exception was not raised.');
} catch (Horde_Mail_Exception $e) {}

$address2 = 'foo@';
$this->assertEquals(
'foo',
$res[0]->mailbox
);
$this->assertNull($res[0]->host);
}
}

try {
$this->rfc822->parseAddressList($address2, array(
'default_domain' => null,
'validate' => true
));
$this->fail('An expected exception was not raised.');
} catch (Horde_Mail_Exception $e) {}
public function testBareMailboxWithoutDefaultDomainWhenValidating()
{
$addresses = array('foo', 'foo@');

foreach ($addresses as $val) {
try {
$this->rfc822->parseAddressList($val, array(
'default_domain' => null,
'validate' => true
));
$this->fail('An expected exception was not raised.');
} catch (Horde_Mail_Exception $e) {}
}
}

}

0 comments on commit 505f50f

Please sign in to comment.