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-- Bug #54440: libxml extension ignores default context --EXTENSIONS-- simplexml --F..

Decoded Output download

--TEST--
Bug #54440: libxml extension ignores default context
--EXTENSIONS--
simplexml
--FILE--
<?php

class TestWrapper {

function stream_open($path, $mode, $options, &$opened_path)
{
    if ($this->context)
        print_r(stream_context_get_options($this->context));
    return false;
}

function url_stat($path, $flags)
{
return array();
}

}

stream_wrapper_register("test", "TestWrapper")
    or die("Failed to register protocol");

$ctx1 = stream_context_create(array('test'=>array('test'=>'test 1')));
$ctx2 = stream_context_create(array('test'=>array('test'=>'test 2')));

stream_context_set_default(stream_context_get_options($ctx1));
@simplexml_load_file('test://sdfsdf');

libxml_set_streams_context($ctx2);
@simplexml_load_file('test://sdfsdf');
?>
--EXPECT--
Array
(
    [test] => Array
        (
            [test] => test 1
        )

)
Array
(
    [test] => Array
        (
            [test] => test 2
        )

)

Did this file decode correctly?

Original Code

--TEST--
Bug #54440: libxml extension ignores default context
--EXTENSIONS--
simplexml
--FILE--
<?php

class TestWrapper {

function stream_open($path, $mode, $options, &$opened_path)
{
    if ($this->context)
        print_r(stream_context_get_options($this->context));
    return false;
}

function url_stat($path, $flags)
{
return array();
}

}

stream_wrapper_register("test", "TestWrapper")
    or die("Failed to register protocol");

$ctx1 = stream_context_create(array('test'=>array('test'=>'test 1')));
$ctx2 = stream_context_create(array('test'=>array('test'=>'test 2')));

stream_context_set_default(stream_context_get_options($ctx1));
@simplexml_load_file('test://sdfsdf');

libxml_set_streams_context($ctx2);
@simplexml_load_file('test://sdfsdf');
?>
--EXPECT--
Array
(
    [test] => Array
        (
            [test] => test 1
        )

)
Array
(
    [test] => Array
        (
            [test] => test 2
        )

)

Function Calls

None

Variables

None

Stats

MD5 038ccb73f9fceecc0da63692206c8ba7
Eval Count 0
Decode Time 106 ms