Skip to content

Commit

Permalink
Merge branch 'hotfix/23-trim-content-type-parameter' into develop
Browse files Browse the repository at this point in the history
Forward port laminas#23
  • Loading branch information
weierophinney committed Jul 28, 2020
2 parents 2c87412 + f0b57c5 commit 69a371a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,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

Expand Down
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 69a371a

Please sign in to comment.