Skip to content

Commit

Permalink
Merge pull request #123 from clue-labs/whitespace-chunks
Browse files Browse the repository at this point in the history
Ignore excessive whitespace in chunk header
  • Loading branch information
WyriHaximus authored Feb 7, 2018
2 parents 924baa2 + f20f7ad commit f8ac7af
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ChunkedStreamDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ protected function iterateBuffer()
list($lengthChunk) = explode(';', $lengthChunk, 2);
}
if ($lengthChunk !== '') {
$lengthChunk = ltrim($lengthChunk, "0");
$lengthChunk = ltrim(trim($lengthChunk), "0");
if ($lengthChunk === '') {
// We've reached the end of the stream
$this->reachedEnd = true;
Expand Down
7 changes: 7 additions & 0 deletions tests/DecodeChunkedStreamTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ public function provideChunkedEncoding()
],
'uppercase-chunk' => [
["4\r\nWiki\r\n5\r\npedia\r\nE\r\n in\r\n\r\nchunks.\r\n0\r\n\r\n"],
],
'extra-space-in-length-chunk' => [
[" 04 \r\nWiki\r\n5\r\npedia\r\nE\r\n in\r\n\r\nchunks.\r\n0\r\n\r\n"],
],
'only-whitespace-is-final-chunk' => [
[" \r\n\r\n"],
""
]
];
}
Expand Down

0 comments on commit f8ac7af

Please sign in to comment.