Skip to content

Commit

Permalink
fix header value parsing, should remove line separations (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
frederikbosch authored Dec 11, 2019
1 parent 25c87f3 commit 4df12c6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Header/HeaderValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public static function fromString(string $headerValueAsString): HeaderValue
{
$values = [];

$headerValueAsString = \trim($headerValueAsString);
$headerValueAsString = \str_replace("\r\n ", '', \trim($headerValueAsString));

$length = \strlen($headerValueAsString) - 1;
$n = -1;
Expand Down
12 changes: 12 additions & 0 deletions test/Unit/Header/HeaderValueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,16 @@ public function it_can_parse_a_string_with_more_than_one_parameter()
$this->assertEquals('charset=utf-8', (string)$header->getParameter('charset'));
$this->assertEquals('foo=bar', (string)$header->getParameter('foo'));
}

/**
* @test
*/
public function it_can_parse_a_string_with_more_than_one_line()
{
$header1 = HeaderValue::fromString("Name \"Quoted Name\"\r\n <[email protected]>");
$header2 = HeaderValue::fromString("Name \"Quoted Name\"\r\n <[email protected]>");

$this->assertEquals('Name "Quoted Name"<[email protected]>', $header1->getRaw());
$this->assertEquals('Name "Quoted Name" <[email protected]>', $header2->getRaw());
}
}

0 comments on commit 4df12c6

Please sign in to comment.