mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2: Restore old namespace reconciliation behaviour
This commit is contained in:
3
NEWS
3
NEWS
@@ -17,6 +17,9 @@ PHP NEWS
|
||||
. Fixed bug GH-11997 (ctype_alnum 5 times slower in PHP 8.1 or greater).
|
||||
(nielsdos)
|
||||
|
||||
- DOM:
|
||||
. Restore old namespace reconciliation behaviour. (nielsdos)
|
||||
|
||||
- Filter:
|
||||
. Fix explicit FILTER_REQUIRE_SCALAR with FILTER_CALLBACK (ilutov)
|
||||
|
||||
|
||||
@@ -1465,11 +1465,16 @@ static void dom_reconcile_ns_internal(xmlDocPtr doc, xmlNodePtr nodep, xmlNodePt
|
||||
|
||||
static void dom_libxml_reconcile_ensure_namespaces_are_declared(xmlNodePtr nodep)
|
||||
{
|
||||
/* Ideally we'd use the DOM-wrapped version, but we cannot: https://github.com/php/php-src/pull/12308. */
|
||||
#if 0
|
||||
/* Put on stack to avoid allocation.
|
||||
* Although libxml2 currently does not use this for the reconciliation, it still
|
||||
* makes sense to do this just in case libxml2's internal change in the future. */
|
||||
xmlDOMWrapCtxt dummy_ctxt = {0};
|
||||
xmlDOMWrapReconcileNamespaces(&dummy_ctxt, nodep, /* options */ 0);
|
||||
#else
|
||||
xmlReconciliateNs(nodep->doc, nodep);
|
||||
#endif
|
||||
}
|
||||
|
||||
void dom_reconcile_ns(xmlDocPtr doc, xmlNodePtr nodep) /* {{{ */
|
||||
|
||||
@@ -123,26 +123,26 @@ bool(true)
|
||||
Toggling namespaces:
|
||||
bool(false)
|
||||
<?xml version="1.0"?>
|
||||
<container xmlns:foo="some:ns2" xmlns:anotherone="some:ns3" xmlns="some:ns"><foo:bar/><baz/></container>
|
||||
<default:container xmlns:foo="some:ns2" xmlns:anotherone="some:ns3" xmlns:default="some:ns"><foo:bar/><default:baz/></default:container>
|
||||
bool(false)
|
||||
<?xml version="1.0"?>
|
||||
<container xmlns:foo="some:ns2" xmlns="some:ns"><foo:bar/><baz/></container>
|
||||
<default:container xmlns:foo="some:ns2" xmlns:default="some:ns"><foo:bar/><default:baz/></default:container>
|
||||
bool(true)
|
||||
<?xml version="1.0"?>
|
||||
<container xmlns:foo="some:ns2" xmlns="some:ns" xmlns:anotherone=""><foo:bar/><baz/></container>
|
||||
<default:container xmlns:foo="some:ns2" xmlns:default="some:ns" xmlns:anotherone=""><foo:bar/><default:baz/></default:container>
|
||||
bool(false)
|
||||
<?xml version="1.0"?>
|
||||
<container xmlns="some:ns" xmlns:anotherone=""><foo:bar xmlns:foo="some:ns2"/><baz/></container>
|
||||
<default:container xmlns:default="some:ns" xmlns:anotherone="" xmlns:foo="some:ns2"><foo:bar/><default:baz/></default:container>
|
||||
bool(false)
|
||||
<?xml version="1.0"?>
|
||||
<container xmlns="some:ns" xmlns:anotherone=""><foo:bar xmlns:foo="some:ns2"/><baz/></container>
|
||||
<default:container xmlns:default="some:ns" xmlns:anotherone="" xmlns:foo="some:ns2"><foo:bar/><default:baz/></default:container>
|
||||
Toggling namespaced attributes:
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(false)
|
||||
<?xml version="1.0"?>
|
||||
<container xmlns="some:ns" xmlns:anotherone="" test:test=""><foo:bar xmlns:foo="some:ns2" foo:test="" doesnotexist:test=""/><baz/></container>
|
||||
<default:container xmlns:default="some:ns" xmlns:anotherone="" xmlns:foo="some:ns2" test:test=""><foo:bar foo:test="" doesnotexist:test=""/><default:baz/></default:container>
|
||||
namespace of test:test = NULL
|
||||
namespace of foo:test = string(8) "some:ns2"
|
||||
namespace of doesnotexist:test = NULL
|
||||
@@ -153,6 +153,6 @@ bool(false)
|
||||
bool(true)
|
||||
bool(false)
|
||||
<?xml version="1.0"?>
|
||||
<container xmlns="some:ns" xmlns:anotherone=""><foo:bar xmlns:foo="some:ns2" doesnotexist:test2=""/><baz/></container>
|
||||
<default:container xmlns:default="some:ns" xmlns:anotherone="" xmlns:foo="some:ns2"><foo:bar doesnotexist:test2=""/><default:baz/></default:container>
|
||||
Checking toggled namespace:
|
||||
string(0) ""
|
||||
|
||||
@@ -118,18 +118,18 @@ test_appendChild_with_shadowing();
|
||||
--EXPECT--
|
||||
-- Test document fragment with import --
|
||||
<?xml version="1.0"?>
|
||||
<html xmlns="https://php.net/something" xmlns:ns="https://php.net/whatever"><element ns:foo="https://php.net/bar"/></html>
|
||||
<html xmlns="https://php.net/something" xmlns:ns="https://php.net/whatever"><default:element xmlns:default="https://php.net/something" ns:foo="https://php.net/bar"/></html>
|
||||
-- Test document fragment without import --
|
||||
<?xml version="1.0"?>
|
||||
<html xmlns=""><element xmlns:foo="https://php.net/bar"><foo:bar/><bar xmlns=""/></element></html>
|
||||
<html xmlns=""><element xmlns:foo="https://php.net/bar"><foo:bar/><bar/></element></html>
|
||||
string(7) "foo:bar"
|
||||
string(19) "https://php.net/bar"
|
||||
-- Test document import --
|
||||
<?xml version="1.0"?>
|
||||
<feed xmlns="http://www.w3.org/2005/Atom">
|
||||
<div xmlns="http://www.w3.org/1999/xhtml">
|
||||
<p>Test-Text</p>
|
||||
</div>
|
||||
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:default="http://www.w3.org/1999/xhtml">
|
||||
<default:div xmlns="http://www.w3.org/1999/xhtml">
|
||||
<default:p>Test-Text</default:p>
|
||||
</default:div>
|
||||
</feed>
|
||||
-- Test partial document import --
|
||||
<?xml version="1.0"?>
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
Bug #47847 (importNode loses the namespace of an XML element)
|
||||
--EXTENSIONS--
|
||||
dom
|
||||
--XFAIL--
|
||||
See https://github.com/php/php-src/pull/12308
|
||||
--FILE--
|
||||
<?php
|
||||
$fromdom = new DOMDocument();
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
Bug #55294 (DOMDocument::importNode shifts namespaces when "default" namespace exists)
|
||||
--EXTENSIONS--
|
||||
dom
|
||||
--XFAIL--
|
||||
See https://github.com/php/php-src/pull/12308
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
|
||||
@@ -43,6 +43,6 @@ string(7) "some:ns"
|
||||
<span xmlns:test="some:ns2" xmlns="some:ns" id="1">
|
||||
|
||||
</span>
|
||||
<span xmlns="some:ns" id="2">Test <test:test xmlns:test="some:ns2"/></span>
|
||||
<default:span xmlns:default="some:ns" xmlns:test="some:ns2" id="2">Test <test:test/></default:span>
|
||||
string(1) "2"
|
||||
string(7) "some:ns"
|
||||
|
||||
27
ext/dom/tests/specific_namespace_behaviour.phpt
Normal file
27
ext/dom/tests/specific_namespace_behaviour.phpt
Normal file
@@ -0,0 +1,27 @@
|
||||
--TEST--
|
||||
DOM: specific namespace behaviour for applications with fixed serialization requirements
|
||||
--EXTENSIONS--
|
||||
dom
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$dom1 = new DOMDocument();
|
||||
$dom1->loadXML(<<<XML
|
||||
<wsse:Security xmlns:wsse="foo:bar">
|
||||
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
|
||||
</ds:Signature>
|
||||
</wsse:Security>
|
||||
XML);
|
||||
$dom2 = new DOMDocument();
|
||||
$dom2->loadXML('<xml><child/></xml>');
|
||||
$wsse = $dom2->importNode($dom1->documentElement, true);
|
||||
$dom2->firstChild->firstChild->appendChild($wsse);
|
||||
echo $dom2->saveXML();
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
<?xml version="1.0"?>
|
||||
<xml><child><wsse:Security xmlns:wsse="foo:bar" xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
|
||||
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
|
||||
</ds:Signature>
|
||||
</wsse:Security></child></xml>
|
||||
@@ -301,8 +301,13 @@ PHP_LIBXML_API void php_libxml_node_free_list(xmlNodePtr node)
|
||||
if (curnode->type == XML_ELEMENT_NODE) {
|
||||
/* This ensures that namespace references in this subtree are defined within this subtree,
|
||||
* otherwise a use-after-free would be possible when the original namespace holder gets freed. */
|
||||
#if 0
|
||||
xmlDOMWrapCtxt dummy_ctxt = {0};
|
||||
xmlDOMWrapReconcileNamespaces(&dummy_ctxt, curnode, /* options */ 0);
|
||||
#else
|
||||
/* See php_dom.c */
|
||||
xmlReconciliateNs(curnode->doc, curnode);
|
||||
#endif
|
||||
}
|
||||
/* Skip freeing */
|
||||
curnode = next;
|
||||
|
||||
Reference in New Issue
Block a user