mirror of
https://github.com/php/php-src.git
synced 2024-09-22 02:17:32 +00:00
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2: Fix #52751: XPath processing-instruction() function is not supported.
This commit is contained in:
commit
2440af0f97
4
NEWS
4
NEWS
@ -34,6 +34,10 @@ PHP NEWS
|
||||
- PCRE:
|
||||
. Update bundled libpcre2 to 10.42. (nielsdos)
|
||||
|
||||
- SimpleXML:
|
||||
. Fixed bug #52751 (XPath processing-instruction() function is not
|
||||
supported). (nielsdos)
|
||||
|
||||
- SPL:
|
||||
. Fixed bug GH-11972 (RecursiveCallbackFilterIterator regression in 8.1.18).
|
||||
(nielsdos)
|
||||
|
@ -1313,7 +1313,7 @@ PHP_METHOD(SimpleXMLElement, xpath)
|
||||
|
||||
for (i = 0; i < result->nodeNr; ++i) {
|
||||
nodeptr = result->nodeTab[i];
|
||||
if (nodeptr->type == XML_TEXT_NODE || nodeptr->type == XML_ELEMENT_NODE || nodeptr->type == XML_ATTRIBUTE_NODE) {
|
||||
if (nodeptr->type == XML_TEXT_NODE || nodeptr->type == XML_ELEMENT_NODE || nodeptr->type == XML_ATTRIBUTE_NODE || nodeptr->type == XML_PI_NODE) {
|
||||
/**
|
||||
* Detect the case where the last selector is text(), simplexml
|
||||
* always accesses the text() child by default, therefore we assign
|
||||
|
58
ext/simplexml/tests/bug52751.phpt
Normal file
58
ext/simplexml/tests/bug52751.phpt
Normal file
@ -0,0 +1,58 @@
|
||||
--TEST--
|
||||
Bug #52751 (XPath processing-instruction() function is not supported)
|
||||
--EXTENSIONS--
|
||||
simplexml
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$xml = <<<XML
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<foo>
|
||||
<bar>text node</bar>
|
||||
<bar><?baz href="ftw" ?></bar>
|
||||
<bar><?foo bar ?></bar>
|
||||
</foo>
|
||||
XML;
|
||||
|
||||
$sxe = simplexml_load_string($xml);
|
||||
|
||||
var_dump(
|
||||
$sxe->xpath('//bar')
|
||||
);
|
||||
|
||||
var_dump(
|
||||
$sxe->xpath('//processing-instruction(\'baz\')')
|
||||
);
|
||||
|
||||
foreach ($sxe->xpath('//processing-instruction()') as $pi) {
|
||||
var_dump($pi->getName());
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
array(3) {
|
||||
[0]=>
|
||||
object(SimpleXMLElement)#2 (1) {
|
||||
[0]=>
|
||||
string(9) "text node"
|
||||
}
|
||||
[1]=>
|
||||
object(SimpleXMLElement)#3 (1) {
|
||||
["baz"]=>
|
||||
object(SimpleXMLElement)#5 (0) {
|
||||
}
|
||||
}
|
||||
[2]=>
|
||||
object(SimpleXMLElement)#4 (1) {
|
||||
["foo"]=>
|
||||
object(SimpleXMLElement)#5 (0) {
|
||||
}
|
||||
}
|
||||
}
|
||||
array(1) {
|
||||
[0]=>
|
||||
object(SimpleXMLElement)#4 (0) {
|
||||
}
|
||||
}
|
||||
string(3) "baz"
|
||||
string(3) "foo"
|
Loading…
Reference in New Issue
Block a user