Skip to content

Commit

Permalink
Ignore empty content parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
slusarz committed Nov 19, 2014
1 parent 4155b9e commit 6cfe9e8
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
8 changes: 7 additions & 1 deletion framework/Mime/lib/Horde/Mime/Part.php
Expand Up @@ -336,6 +336,10 @@ public function getDisposition()
*/
public function setDispositionParameter($label, $data)
{
if (!strlen($data)) {
return;
}

$this->_dispParams[$label] = $data;

switch ($label) {
Expand Down Expand Up @@ -988,7 +992,9 @@ protected function _partAction($id, $action, $mime_part = null)
*/
public function setContentTypeParameter($label, $data)
{
$this->_contentTypeParams[$label] = $data;
if (strlen($data)) {
$this->_contentTypeParams[$label] = $data;
}
}

/**
Expand Down
25 changes: 25 additions & 0 deletions framework/Mime/test/Horde/Mime/PartTest.php
Expand Up @@ -671,6 +671,31 @@ public function testAccessingMimePartsInRawText()
);
}

/**
* @dataProvider setCharsetProvider
*/
public function testSetCharset($charset, $expected)
{
$part = new Horde_Mime_Part();
$part->setType('text/plain');
$part->setCharset($charset);

$this->assertEquals(
$expected,
$part->getType(true)
);
}

public function setCharsetProvider()
{
return array(
array('utf-8', 'text/plain; charset=utf-8'),
array('UtF-8', 'text/plain; charset=utf-8'),
array('us-ascii', 'text/plain'),
array('', 'text/plain')
);
}

protected function _getTestPart()
{
$part = new Horde_Mime_Part();
Expand Down

0 comments on commit 6cfe9e8

Please sign in to comment.