Skip to content
Permalink
Browse files

Bug: 14456 Ensure address-type headers are MIME decoded.

This got lost during the refactoring to the individual
Horde_Mime_Header* objects. Fixes incorrect parsing of email
address lists when source headers are MIME encoded.
  • Loading branch information...
mrubinsk committed Sep 5, 2016
1 parent b0ad380 commit 9cf5454ce4517426b6b612562caf118721fe5390
@@ -64,6 +64,14 @@ public function getAddressList($first = false)
: array($this->_values);
}
protected function _decodeMime($value)
{
if (is_object($value)) {
return $value;
}
return Horde_Mime::decode($value);
}
/**
*
* @throws Horde_Mime_Exception
@@ -73,6 +81,16 @@ protected function _setValue($value)
/* @todo Implement with traits */
$rfc822 = new Horde_Mail_Rfc822();
// Ensure values are MIME decoded.
// @see Bug 14456
if (is_array($value)) {
foreach ($value as &$adr) {
$adr = $this->_decodeMime($adr);
}
} else {
$value = $this->_decodeMime($value);
}
try {
$addr_list = $rfc822->parseAddressList($value);
} catch (Horde_Mail_Exception $e) {
@@ -109,6 +109,42 @@ public function serializeProvider()
);
}
/**
* @dataProvider mimeEncodedAddressProvider
*/
public function testBug14456($header, $value, $decoded)
{
$hdrs = new Horde_Mime_Headers();
$hdrs->addHeader($header, $value);
$this->assertEquals($decoded, $hdrs->getValue($header));
}
public function mimeEncodedAddressProvider()
{
return array(
array(
'To',
'=?utf-8?Q?"Mike,_H=C3=A5vard"?= <mike@example.com>',
'"Mike, Håvard" <mike@example.com>'
),
array(
'To',
'=?utf-8?Q?"Steve,_H=C3=A5vard"?= <steve@example.com>, =?utf-8?Q?"Bob,_H=C3=A5vard"?= <bob@example.com>',
'"Steve, Håvard" <steve@example.com>, "Bob, Håvard" <bob@example.com>'
),
array(
'To',
'sheldon@example.com',
'sheldon@example.com'
),
array(
'From',
'=?utf-8?Q?"Mike,_H=C3=A5vard"?= <mike@example.com>',
'"Mike, Håvard" <mike@example.com>'
)
);
}
/**
* @dataProvider normalHeaderDecodeProvider
*/

0 comments on commit 9cf5454

Please sign in to comment.
You can’t perform that action at this time.