mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Refactored the fix for bug #66084, by cmb@php.net
This commit is contained in:
parent
c4e9651b58
commit
5683b6fa39
8 changed files with 303 additions and 1 deletions
4
NEWS
4
NEWS
|
@ -35,6 +35,10 @@
|
|||
. Fixed bug #69549 (Memory leak with opcache.optimization_level=0xFFFFFFFF).
|
||||
(Laruence, Dmitry)
|
||||
|
||||
- SimpleXML:
|
||||
. Refactored the fix for bug #66084 (simplexml_load_string() mangles empty
|
||||
node name). (Christoph Michael Becker)
|
||||
|
||||
14 May 2015, PHP 5.5.25
|
||||
|
||||
- Core:
|
||||
|
|
|
@ -1129,7 +1129,7 @@ static HashTable * sxe_get_prop_hash(zval *object, int is_debug TSRMLS_DC) /* {{
|
|||
node = NULL;
|
||||
} else if (sxe->iter.type != SXE_ITER_CHILD) {
|
||||
|
||||
if ( !node->children || !node->parent || !node->next || node->children->next || node->children->children || node->parent->children == node->parent->last ) {
|
||||
if ( sxe->iter.type == SXE_ITER_NONE || !node->children || !node->parent || node->children->next || node->children->children || node->parent->children == node->parent->last ) {
|
||||
node = node->children;
|
||||
} else {
|
||||
iter_data = sxe->iter.data;
|
||||
|
|
19
ext/simplexml/tests/bug61335.phpt
Normal file
19
ext/simplexml/tests/bug61335.phpt
Normal file
|
@ -0,0 +1,19 @@
|
|||
--TEST--
|
||||
Bug #61335 - Access to array node returns wrong truth value
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("simplexml")) die("skip SimpleXML not available");
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$rec1 = simplexml_load_string("<foo><bar>aa</bar>\n</foo>");
|
||||
$rec2 = simplexml_load_string("<foo><bar>aa</bar></foo>");
|
||||
|
||||
if ($rec1->bar[0]) echo "NONEMPTY1\n";
|
||||
if ($rec1->bar[0] . "") echo "NONEMPTY2\n";
|
||||
if ($rec2->bar[0]) echo "NONEMPTY3\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
NONEMPTY1
|
||||
NONEMPTY2
|
||||
NONEMPTY3
|
63
ext/simplexml/tests/bug62639.phpt
Normal file
63
ext/simplexml/tests/bug62639.phpt
Normal file
|
@ -0,0 +1,63 @@
|
|||
--TEST--
|
||||
Bug #62639 (XML structure broken)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("simplexml")) die("skip SimpleXML not available");
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
class A extends SimpleXMLElement
|
||||
{
|
||||
}
|
||||
|
||||
$xml1 = <<<XML
|
||||
<?xml version="1.0"?>
|
||||
<a>
|
||||
<b>
|
||||
<c>
|
||||
<value attr="Some Attr">Some Value</value>
|
||||
</c>
|
||||
</b>
|
||||
</a>
|
||||
XML;
|
||||
|
||||
$a1 = new A($xml1);
|
||||
|
||||
foreach ($a1->b->c->children() as $key => $value) {
|
||||
var_dump($value);
|
||||
}
|
||||
|
||||
$xml2 = <<<XML
|
||||
<?xml version="1.0"?>
|
||||
<a>
|
||||
<b>
|
||||
<c><value attr="Some Attr">Some Value</value></c>
|
||||
</b>
|
||||
</a>
|
||||
XML;
|
||||
|
||||
$a2 = new A($xml2);
|
||||
|
||||
foreach ($a2->b->c->children() as $key => $value) {
|
||||
var_dump($value);
|
||||
}?>
|
||||
--EXPECT--
|
||||
object(A)#2 (2) {
|
||||
["@attributes"]=>
|
||||
array(1) {
|
||||
["attr"]=>
|
||||
string(9) "Some Attr"
|
||||
}
|
||||
[0]=>
|
||||
string(10) "Some Value"
|
||||
}
|
||||
object(A)#3 (2) {
|
||||
["@attributes"]=>
|
||||
array(1) {
|
||||
["attr"]=>
|
||||
string(9) "Some Attr"
|
||||
}
|
||||
[0]=>
|
||||
string(10) "Some Value"
|
||||
}
|
93
ext/simplexml/tests/bug67116.phpt
Normal file
93
ext/simplexml/tests/bug67116.phpt
Normal file
|
@ -0,0 +1,93 @@
|
|||
--TEST--
|
||||
Bug #67116 (Inconsistent parsing of Nodes w/o linefeed)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("simplexml")) die("skip SimpleXML not available");
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$xml = <<<XML
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<aa>
|
||||
<bs>
|
||||
<b>b</b>
|
||||
</bs>
|
||||
<cs><c>b</c></cs>
|
||||
<ds><d id="d"></d></ds>
|
||||
<es>
|
||||
<e id="e"></e>
|
||||
</es>
|
||||
<fs><f id="f"></f><f id="f"></f></fs>
|
||||
</aa>
|
||||
XML;
|
||||
$sxe = simplexml_load_string($xml);
|
||||
print_r($sxe);
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
SimpleXMLElement Object
|
||||
(
|
||||
[bs] => SimpleXMLElement Object
|
||||
(
|
||||
[b] => b
|
||||
)
|
||||
|
||||
[cs] => SimpleXMLElement Object
|
||||
(
|
||||
[c] => b
|
||||
)
|
||||
|
||||
[ds] => SimpleXMLElement Object
|
||||
(
|
||||
[d] => SimpleXMLElement Object
|
||||
(
|
||||
[@attributes] => Array
|
||||
(
|
||||
[id] => d
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
[es] => SimpleXMLElement Object
|
||||
(
|
||||
[e] => SimpleXMLElement Object
|
||||
(
|
||||
[@attributes] => Array
|
||||
(
|
||||
[id] => e
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
[fs] => SimpleXMLElement Object
|
||||
(
|
||||
[f] => Array
|
||||
(
|
||||
[0] => SimpleXMLElement Object
|
||||
(
|
||||
[@attributes] => Array
|
||||
(
|
||||
[id] => f
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
[1] => SimpleXMLElement Object
|
||||
(
|
||||
[@attributes] => Array
|
||||
(
|
||||
[id] => f
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
)
|
33
ext/simplexml/tests/bug67572.phpt
Normal file
33
ext/simplexml/tests/bug67572.phpt
Normal file
|
@ -0,0 +1,33 @@
|
|||
--TEST--
|
||||
Bug #67572 - SimpleXMLElement not parsing \n correctly
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("simplexml")) die("skip SimpleXML not available");
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$foo = 'bar';
|
||||
print "regular string ... ";
|
||||
var_dump(empty($foo));
|
||||
|
||||
$xml = simplexml_load_string("<xml><something>somevalue</something></xml>");
|
||||
$xml2 = simplexml_load_string("<xml>\n<something>somevalue</something>\n</xml>");
|
||||
|
||||
foreach($xml as $key => $value) {
|
||||
print "$key = $value ... ";
|
||||
var_dump(empty($value));
|
||||
var_dump($value == false);
|
||||
}
|
||||
|
||||
foreach($xml2 as $key => $value) {
|
||||
print "$key = $value ... ";
|
||||
var_dump(empty($value));
|
||||
var_dump($value == false);
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
regular string ... bool(false)
|
||||
something = somevalue ... bool(false)
|
||||
bool(false)
|
||||
something = somevalue ... bool(false)
|
||||
bool(false)
|
70
ext/simplexml/tests/bug69169.phpt
Normal file
70
ext/simplexml/tests/bug69169.phpt
Normal file
|
@ -0,0 +1,70 @@
|
|||
--TEST--
|
||||
Bug #69169 (simplexml_load_string parse wrongly when xml given in one row)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("simplexml")) die("skip SimpleXML not available");
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$a = '<?xml version="1.0" encoding="UTF-8"?>
|
||||
<root a="b">
|
||||
<row b="y">
|
||||
<item s="t" />
|
||||
</row>
|
||||
<row p="c">
|
||||
<item y="n" />
|
||||
</row>
|
||||
</root>';
|
||||
$b = str_replace(array("\n", "\r", "\t"), "", $a);
|
||||
$simple_xml = simplexml_load_string($b);
|
||||
print_r($simple_xml);
|
||||
?>
|
||||
--EXPECT--
|
||||
SimpleXMLElement Object
|
||||
(
|
||||
[@attributes] => Array
|
||||
(
|
||||
[a] => b
|
||||
)
|
||||
|
||||
[row] => Array
|
||||
(
|
||||
[0] => SimpleXMLElement Object
|
||||
(
|
||||
[@attributes] => Array
|
||||
(
|
||||
[b] => y
|
||||
)
|
||||
|
||||
[item] => SimpleXMLElement Object
|
||||
(
|
||||
[@attributes] => Array
|
||||
(
|
||||
[s] => t
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
[1] => SimpleXMLElement Object
|
||||
(
|
||||
[@attributes] => Array
|
||||
(
|
||||
[p] => c
|
||||
)
|
||||
|
||||
[item] => SimpleXMLElement Object
|
||||
(
|
||||
[@attributes] => Array
|
||||
(
|
||||
[y] => n
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
)
|
20
ext/simplexml/tests/bug69491.phpt
Normal file
20
ext/simplexml/tests/bug69491.phpt
Normal file
|
@ -0,0 +1,20 @@
|
|||
--TEST--
|
||||
Bug #69491 (simplexml doesn't correctly parse empty nodes on same line as another node)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("simplexml")) die("skip SimpleXML not available");
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
var_dump(simplexml_load_string('<a>
|
||||
<b><c/></b>
|
||||
</a>'));?>
|
||||
--EXPECT--
|
||||
object(SimpleXMLElement)#1 (1) {
|
||||
["b"]=>
|
||||
object(SimpleXMLElement)#2 (1) {
|
||||
["c"]=>
|
||||
object(SimpleXMLElement)#3 (0) {
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue