Made HttpSocket::decodeChunkedBody a little more forgiving, fixes #4523

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6752 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
the_undefined 2008-05-05 12:42:15 +00:00
parent 9097b25111
commit 268bb42a02
2 changed files with 5 additions and 1 deletions

View file

@ -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;

View file

@ -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);