Skip to content

Commit e5d0e62

Browse files
committed
Merge branch 'PHP-8.5'
* PHP-8.5: Fix getNamedItemNS() incorrect namespace check
2 parents 264d650 + 8392633 commit e5d0e62

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

ext/dom/obj_map.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -515,11 +515,11 @@ static xmlNodePtr dom_map_get_ns_named_item_prop(dom_nnodemap_object *map, const
515515
{
516516
xmlNodePtr nodep = dom_object_get_node(map->baseobj);
517517
if (nodep) {
518-
if (php_dom_follow_spec_intern(map->baseobj)) {
519-
return (xmlNodePtr) php_dom_get_attribute_node(nodep, BAD_CAST ZSTR_VAL(named), ZSTR_LEN(named));
518+
if (ns) {
519+
return (xmlNodePtr) xmlHasNsProp(nodep, BAD_CAST ZSTR_VAL(named), BAD_CAST ns);
520520
} else {
521-
if (ns) {
522-
return (xmlNodePtr) xmlHasNsProp(nodep, BAD_CAST ZSTR_VAL(named), BAD_CAST ns);
521+
if (php_dom_follow_spec_intern(map->baseobj)) {
522+
return (xmlNodePtr) php_dom_get_attribute_node(nodep, BAD_CAST ZSTR_VAL(named), ZSTR_LEN(named));
523523
} else {
524524
return (xmlNodePtr) xmlHasProp(nodep, BAD_CAST ZSTR_VAL(named));
525525
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--TEST--
2+
getNamedItemNS() incorrect namespace check
3+
--EXTENSIONS--
4+
dom
5+
--CREDITS--
6+
veewee
7+
--FILE--
8+
<?php
9+
10+
$xml = Dom\XMLDocument::createFromString(<<<EOXML
11+
<?xml version="1.0" encoding="UTF-8"?>
12+
<note
13+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
14+
xsi:noNamespaceSchemaLocation="note-nonamespace1.xsd http://localhost/note-nonamespace2.xsd"
15+
xsi:schemaLocation="http://www.happy-helpers1.com note-namespace1.xsd http://www.happy-helpers2.com http://localhost/note-namespace2.xsd">
16+
</note>
17+
EOXML
18+
);
19+
$documentElement = $xml->documentElement;
20+
$attributes = $documentElement->attributes;
21+
$schemaLocation = $attributes->getNamedItemNS('http://www.w3.org/2001/XMLSchema-instance', 'schemaLocation');
22+
var_dump($schemaLocation->textContent);
23+
24+
?>
25+
--EXPECT--
26+
string(116) "http://www.happy-helpers1.com note-namespace1.xsd http://www.happy-helpers2.com http://localhost/note-namespace2.xsd"

0 commit comments

Comments
 (0)