mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Making HttpResponse more tolerant of line endings.
This commit is contained in:
parent
cfbc6d4989
commit
89ced25fad
2 changed files with 10 additions and 1 deletions
|
@ -204,7 +204,7 @@ class HttpResponse implements ArrayAccess {
|
|||
$chunkLength = null;
|
||||
|
||||
while ($chunkLength !== 0) {
|
||||
if (!preg_match("/^([0-9a-f]+) *(?:;(.+)=(.+))?\r\n/iU", $body, $match)) {
|
||||
if (!preg_match('/^([0-9a-f]+) *(?:;(.+)=(.+))?(?:\r\n|\n)/iU', $body, $match)) {
|
||||
throw new SocketException(__d('cake_dev', 'HttpSocket::_decodeChunkedBody - Could not parse malformed chunk.'));
|
||||
}
|
||||
|
||||
|
|
|
@ -320,6 +320,15 @@ class HttpResponseTest extends CakeTestCase {
|
|||
|
||||
$r = $this->HttpResponse->decodeBody($sample['encoded'], $encoding);
|
||||
$this->assertEquals($r, $sample['decoded']);
|
||||
|
||||
$encoding = 'chunked';
|
||||
$sample = array(
|
||||
'encoded' => "19\nThis is a chunked message\r\n0\n",
|
||||
'decoded' => array('body' => "This is a chunked message", 'header' => false)
|
||||
);
|
||||
|
||||
$r = $this->HttpResponse->decodeBody($sample['encoded'], $encoding);
|
||||
$this->assertEquals($r, $sample['decoded'], 'Inconsistent line terminators should be tolerated.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue