Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

--TEST-- Chunked encoding --SKIPIF-- <?php $filters = stream_get_filters(); if(! in_array(..

Decoded Output download

--TEST--
Chunked encoding
--SKIPIF--
<?php
$filters = stream_get_filters();
if(! in_array( "dechunk", $filters )) die( "skip Chunked filter not available." );
?>
--INI--
allow_url_fopen=1
--FILE--
<?php
$streams = array(
    "data://text/plain,0
",
    "data://text/plain,2
te
2
st
0
",
    "data://text/plain,2
te
2
st
0
",
    "data://text/plain,2;a=1
te
2;a=2;b=3
st
0
",
    "data://text/plain,2
te
2
st
0
a=b
c=d

",
    "data://text/plain,1f
0123456789abcdef0123456789abcde
1
f
0
",
    "data://text/plain,1E
0123456789abcdef0123456789abcd
2
ef
0
",
);
foreach ($streams as $name) {
    $fp = fopen($name, "r");
    stream_filter_append($fp, "dechunk", STREAM_FILTER_READ);
    var_dump(stream_get_contents($fp));
    fclose($fp);
}
?>
--EXPECT--
string(0) ""
string(4) "test"
string(4) "test"
string(4) "test"
string(4) "test"
string(32) "0123456789abcdef0123456789abcdef"
string(32) "0123456789abcdef0123456789abcdef"

Did this file decode correctly?

Original Code

--TEST--
Chunked encoding
--SKIPIF--
<?php
$filters = stream_get_filters();
if(! in_array( "dechunk", $filters )) die( "skip Chunked filter not available." );
?>
--INI--
allow_url_fopen=1
--FILE--
<?php
$streams = array(
    "data://text/plain,0\r\n",
    "data://text/plain,2\r\nte\r\n2\r\nst\r\n0\r\n",
    "data://text/plain,2\nte\n2\nst\n0\n",
    "data://text/plain,2;a=1\nte\n2;a=2;b=3\r\nst\n0\n",
    "data://text/plain,2\nte\n2\nst\n0\na=b\r\nc=d\n\r\n",
    "data://text/plain,1f\n0123456789abcdef0123456789abcde\n1\nf\n0\n",
    "data://text/plain,1E\n0123456789abcdef0123456789abcd\n2\nef\n0\n",
);
foreach ($streams as $name) {
    $fp = fopen($name, "r");
    stream_filter_append($fp, "dechunk", STREAM_FILTER_READ);
    var_dump(stream_get_contents($fp));
    fclose($fp);
}
?>
--EXPECT--
string(0) ""
string(4) "test"
string(4) "test"
string(4) "test"
string(4) "test"
string(32) "0123456789abcdef0123456789abcdef"
string(32) "0123456789abcdef0123456789abcdef"

Function Calls

stream_get_filters 1

Variables

None

Stats

MD5 ad480dab3747683b2425b31d51f168f3
Eval Count 0
Decode Time 82 ms