Skip to content

Commit

Permalink
Fixes #23 ensure trim() on ContentType::addParameter()
Browse files Browse the repository at this point in the history
Signed-off-by: Abdul Malik Ikhsan <[email protected]>
  • Loading branch information
samsonasik committed Jul 24, 2020
1 parent aa1a4c9 commit a39d6f2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Header/ContentType.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public function getType()
*/
public function addParameter($name, $value)
{
$name = strtolower($name);
$name = trim(strtolower($name));
$value = (string) $value;

if (! HeaderValue::isValid($name)) {
Expand Down
6 changes: 6 additions & 0 deletions test/Header/ContentTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,12 @@ public function testGetParameter()
$this->assertSame('top', $header->getParameter('level'));
}

public function testGetParameterWithSpaceTrimmed()
{
$header = ContentType::fromString('content-type: text/plain; level=top; name="logfile.log";');
$this->assertSame('logfile.log', $header->getParameter('name'));
}

public function testGetParameterNotExists()
{
$header = ContentType::fromString('content-type: text/plain');
Expand Down

0 comments on commit a39d6f2

Please sign in to comment.