From 2433276fbe2f0aa86e3b9fa71ecbe0de95ff6a8d Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Fri, 24 Jul 2020 13:06:41 +0700 Subject: [PATCH 1/2] Fixes #23 ensure trim() on ContentType::addParameter() Signed-off-by: Abdul Malik Ikhsan --- src/Header/ContentType.php | 2 +- test/Header/ContentTypeTest.php | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) 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'); From f0b57c5270d6c2d710ea5e27472508bda250ea68 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Tue, 28 Jul 2020 16:13:58 -0500 Subject: [PATCH 2/2] docs: adds CHANGELOG entry for #97 Signed-off-by: Matthew Weier O'Phinney --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e666bbc..71d27a5e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,7 +22,7 @@ All notable changes to this project will be documented in this file, in reverse ### Fixed -- Nothing. +- [#97](https://github.com/laminas/laminas-mail/pull/97) adds code to `Header\ContentType::addParameter()` to ensure the value is trimmed of whitespace, fixing issues whereby filenames might contain a leading or trailing space. ## 2.11.0 - 2020-06-30