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 #46699: (xml_parse crash when parser is namespace aware) --EXTENSIONS-- xml -..

Decoded Output download

--TEST--
Bug #46699: (xml_parse crash when parser is namespace aware)
--EXTENSIONS--
xml
--SKIPIF--
<?php
if (! @xml_parser_create_ns('ISO-8859-1')) { die("skip xml_parser_create_ns is not supported on this platform");}
?>
--FILE--
<?php
function defaultfunc($parser, $data)
{
echo $data;
}

$xml = <<<HERE
<a xmlns="http://example.com/foo"
    xmlns:bar="http://example.com/bar">
  <bar:b foo="bar">1</bar:b>
  <bar:c bar:nix="null" foo="bar">2</bar:c>
</a>
HERE;

$parser = xml_parser_create_ns("ISO-8859-1","@");
xml_set_default_handler($parser,'defaultfunc');
xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
xml_parse($parser, $xml);
xml_parser_free($parser);
?>
--EXPECT--
<a xmlns="http://example.com/foo" xmlns:bar="http://example.com/bar">
  <bar:b foo="bar">1</bar:b>
  <bar:c bar:nix="null" foo="bar">2</bar:c>
</a>

Did this file decode correctly?

Original Code

--TEST--
Bug #46699: (xml_parse crash when parser is namespace aware)
--EXTENSIONS--
xml
--SKIPIF--
<?php
if (! @xml_parser_create_ns('ISO-8859-1')) { die("skip xml_parser_create_ns is not supported on this platform");}
?>
--FILE--
<?php
function defaultfunc($parser, $data)
{
echo $data;
}

$xml = <<<HERE
<a xmlns="http://example.com/foo"
    xmlns:bar="http://example.com/bar">
  <bar:b foo="bar">1</bar:b>
  <bar:c bar:nix="null" foo="bar">2</bar:c>
</a>
HERE;

$parser = xml_parser_create_ns("ISO-8859-1","@");
xml_set_default_handler($parser,'defaultfunc');
xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
xml_parse($parser, $xml);
xml_parser_free($parser);
?>
--EXPECT--
<a xmlns="http://example.com/foo" xmlns:bar="http://example.com/bar">
  <bar:b foo="bar">1</bar:b>
  <bar:c bar:nix="null" foo="bar">2</bar:c>
</a>

Function Calls

xml_parser_create_ns 1

Variables

None

Stats

MD5 a7b35e8d40d281ff189a091f4924fb59
Eval Count 0
Decode Time 100 ms