diff --git a/cake/libs/http_socket.php b/cake/libs/http_socket.php index a8c04a123..4b1bf3ac5 100644 --- a/cake/libs/http_socket.php +++ b/cake/libs/http_socket.php @@ -469,7 +469,7 @@ class HttpSocket extends CakeSocket { $chunkLength = null; while ($chunkLength !== 0) { - if (!preg_match("/^([0-9a-f]+)(?:;(.+)=(.+))?\r\n/iU", $body, $match)) { + if (!preg_match("/^([0-9a-f]+) *(?:;(.+)=(.+))?\r\n/iU", $body, $match)) { if (!$this->quirksMode) { trigger_error(__('HttpSocket::decodeChunkedBody - Could not parse malformed chunk. Activate quirks mode to do this.', true), E_USER_WARNING); return false; diff --git a/cake/tests/cases/libs/http_socket.test.php b/cake/tests/cases/libs/http_socket.test.php index ec4062f9e..58bfb71cb 100644 --- a/cake/tests/cases/libs/http_socket.test.php +++ b/cake/tests/cases/libs/http_socket.test.php @@ -639,6 +639,10 @@ class HttpSocketTest extends UnitTestCase { $this->assertIdentical($r['body'], $decoded); $this->assertIdentical($r['header'], false); + $encoded = "19 \r\nThis is a chunked message\r\n0\r\n"; + $r = $this->Socket->decodeChunkedBody($encoded); + $this->assertIdentical($r['body'], $decoded); + $encoded = "19\r\nThis is a chunked message\r\nE\r\n\nThat is cool\n\r\n0\r\n"; $decoded = "This is a chunked message\nThat is cool\n"; $r = $this->Socket->decodeChunkedBody($encoded);