Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/zendframework/zendframework#6491-remove-empty-va…
Browse files Browse the repository at this point in the history
…lues-from-parsed-header' into develop

Forward port zendframework/zendframework#6491
  • Loading branch information
Ocramius committed Aug 6, 2014
7 parents fe14f39 + 26177b0 + 2beabf9 + de855cb + 82571c3 + d3c79d6 + e23e54e commit 569a04b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/Header/ContentType.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ public static function fromString($headerLine)
$values = preg_split('#\s*;\s*#', $value);
$type = array_shift($values);

//Remove empty values
$values = array_filter($values);

$header = new static();
$header->setType($type);

Expand Down
14 changes: 13 additions & 1 deletion test/Header/ContentTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ public function testContentTypeToStringReturnsHeaderFormattedString()
$this->assertEquals("Content-Type: foo/bar", $contentTypeHeader->toString());
}

/**
* @group 6491
*/
public function testTrailingSemiColonFromString()
{
$contentTypeHeader = ContentType::fromString(
'Content-Type: multipart/alternative; boundary="Apple-Mail=_1B852F10-F9C6-463D-AADD-CD503A5428DD";'
);
$params = $contentTypeHeader->getParameters();
$this->assertEquals($params, array('boundary' => 'Apple-Mail=_1B852F10-F9C6-463D-AADD-CD503A5428DD'));
}

public function testProvidingParametersIntroducesHeaderFolding()
{
$header = new ContentType();
Expand All @@ -61,7 +73,7 @@ public function testExtractsExtraInformationFromContentType()
'Content-Type: multipart/alternative; boundary="Apple-Mail=_1B852F10-F9C6-463D-AADD-CD503A5428DD"'
);
$params = $contentTypeHeader->getParameters();
$this->assertEquals($params,array('boundary' => 'Apple-Mail=_1B852F10-F9C6-463D-AADD-CD503A5428DD'));
$this->assertEquals($params, array('boundary' => 'Apple-Mail=_1B852F10-F9C6-463D-AADD-CD503A5428DD'));
}

public function testExtractsExtraInformationWithoutBeingConfusedByTrailingSemicolon()
Expand Down

0 comments on commit 569a04b

Please sign in to comment.