8000 Merge pull request #123 from clue-labs/whitespace-chunks · reactphp/http-client@f8ac7af · GitHub
[go: up one dir, main page]

Skip to content

Commit f8ac7af

Browse files
authored
Merge pull request #123 from clue-labs/whitespace-chunks
Ignore exc 8000 essive whitespace in chunk header
2 parents 924baa2 + f20f7ad commit f8ac7af

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/ChunkedStreamDecoder.php

Lines changed: 1 addition & 1 deletion
Original file line number 8000 Diff line numberDiff line change
@@ -103,7 +103,7 @@ protected function iterateBuffer()
103103
list($lengthChunk) = explode(';', $lengthChunk, 2);
104104
}
105105
if ($lengthChunk !== '') {
106-
$lengthChunk = ltrim($lengthChunk, "0");
106+
$lengthChunk = ltrim(trim($lengthChunk), "0");
107107
if ($lengthChunk === '') {
108108
// We've reached the end of the stream
109109
$this->reachedEnd = true;

tests/DecodeChunkedStreamTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,13 @@ public function provideChunkedEncoding()
7676
],
7777
'uppercase-chunk' => [
7878
["4\r\nWiki\r\n5\r\npedia\r\nE\r\n in\r\n\r\nchunks.\r\n0\r\n\r\n"],
79+
],
80+
'extra-space-in-length-chunk' => [
81+
[" 04 \r\nWiki\r\n5\r\npedia\r\nE\r\n in\r\n\r\nchunks.\r\n0\r\n\r\n"],
82+
],
83+
'only-whitespace-is-final-chunk' => [
84+
[" \r\n\r\n"],
85+
""
7986
]
8087
];
8188
}

0 commit comments

Comments
 (0)
0