Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Fix and test header factory
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasvargiu committed Jan 13, 2019
1 parent d4e39ed commit 16220f4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/Headers.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,10 @@ public static function fromString($string)

if (preg_match("/^[ \t][^\r\n]*$/", $line, $matches)) {
// continuation: append to current line
if (! isset($current['line'])) {
$current['line'] = '';
if (isset($current['line'])) {
$current['line'] .= trim($line);
continue;
}

$current['line'] .= trim($line);
continue;
}

// Line does not match header format!
Expand Down
6 changes: 6 additions & 0 deletions test/HeadersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -315,4 +315,10 @@ public function testCRLFAttack()
$this->expectException(RuntimeException::class);
Headers::fromString("Fake: foo-bar\r\n\r\nevilContent");
}

public function testHeadersFromStringFactoryWithNoCurrentLineShouldThrowException()
{
$this->expectException(RuntimeException::class);
Headers::fromString(" Fake foo\r\n -bar");
}
}

0 comments on commit 16220f4

Please sign in to comment.