diff --git a/src/Header/ContentType.php b/src/Header/ContentType.php index 8ffc7c6d..3b57df46 100644 --- a/src/Header/ContentType.php +++ b/src/Header/ContentType.php @@ -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)) { diff --git a/test/Header/ContentTypeTest.php b/test/Header/ContentTypeTest.php index c7386a86..4d3f9b3a 100644 --- a/test/Header/ContentTypeTest.php +++ b/test/Header/ContentTypeTest.php @@ -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');