Skip to content

Commit

Permalink
[mms] Fix cloning of the Content-Type and Content-Disposition header …
Browse files Browse the repository at this point in the history
…objects.
  • Loading branch information
slusarz committed Jan 21, 2015
1 parent f2a32b1 commit 07e96f4
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
9 changes: 9 additions & 0 deletions framework/Mime/lib/Horde/Mime/Headers/ContentParam.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ class Horde_Mime_Headers_ContentParam
*/
protected $_params;

/**
*/
public function __clone()
{
$this->_params = new Horde_Support_CaseInsensitiveArray(
$this->_params->getArrayCopy()
);
}

/**
*/
public function __get($name)
Expand Down
4 changes: 2 additions & 2 deletions framework/Mime/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</stability>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
*
* [mms] Fix cloning of the Content-Type and Content-Disposition header objects.
</notes>
<contents>
<dir baseinstalldir="/" name="/">
Expand Down Expand Up @@ -1619,7 +1619,7 @@
<date>2015-01-20</date>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
*
* [mms] Fix cloning of the Content-Type and Content-Disposition header objects.
</notes>
</release>
</changelog>
Expand Down
22 changes: 22 additions & 0 deletions framework/Mime/test/Horde/Mime/HeadersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,24 @@ public function testClone()
$hdrs->addHeader('Resent-To', 'foo2@example.com');
$hdrs->addHeader('Resent-To', 'foo3@example.com');

$ct = new Horde_Mime_Headers_ContentParam(
'Content-Type',
'text/plain; charset="us-ascii"'
);
$hdrs->addHeaderOb($ct);

$cd = new Horde_Mime_Headers_ContentParam(
'Content-Disposition',
'attachment; filename="foo"'
);
$hdrs->addHeaderOb($cd);

$hdrs2 = clone $hdrs;

$hdrs->addHeader('To', 'bar@example.com');
$hdrs->addHeader('Resent-To', 'bar2@example.com');
$ct['charset'] = 'utf-8';
$cd['filename'] = 'bar';

$this->assertEquals(
'foo@example.com',
Expand All @@ -42,6 +56,14 @@ public function testClone()
array('foo2@example.com', 'foo3@example.com'),
$hdrs2['Resent-To']->value
);
$this->assertEquals(
array('charset' => 'us-ascii'),
$hdrs2['Content-Type']->params
);
$this->assertEquals(
array('filename' => 'foo'),
$hdrs2['Content-Disposition']->params
);
}

/**
Expand Down

0 comments on commit 07e96f4

Please sign in to comment.