mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Fix GH-17397: Assertion failure ext/dom/php_dom.c
The problem was that the property hash tables were not merging the correct ones, a stupid typo (or caused by merging). Closes GH-17406.
This commit is contained in:
parent
71493623f4
commit
6d215981b6
5 changed files with 63 additions and 84 deletions
3
NEWS
3
NEWS
|
@ -6,6 +6,9 @@ PHP NEWS
|
||||||
. Fixed bug GH-17234 (Numeric parent hook call fails with assertion).
|
. Fixed bug GH-17234 (Numeric parent hook call fails with assertion).
|
||||||
(nielsdos)
|
(nielsdos)
|
||||||
|
|
||||||
|
- DOM:
|
||||||
|
. Fixed bug GH-17397 (Assertion failure ext/dom/php_dom.c). (nielsdos)
|
||||||
|
|
||||||
- FTP:
|
- FTP:
|
||||||
. Fixed bug GH-16800 (ftp functions can abort with EINTR). (nielsdos)
|
. Fixed bug GH-16800 (ftp functions can abort with EINTR). (nielsdos)
|
||||||
|
|
||||||
|
|
|
@ -1080,7 +1080,7 @@ PHP_MINIT_FUNCTION(dom)
|
||||||
DOM_REGISTER_PROP_HANDLER(&dom_modern_attr_prop_handlers, "value", dom_attr_value_read, dom_attr_value_write);
|
DOM_REGISTER_PROP_HANDLER(&dom_modern_attr_prop_handlers, "value", dom_attr_value_read, dom_attr_value_write);
|
||||||
DOM_REGISTER_PROP_HANDLER(&dom_modern_attr_prop_handlers, "ownerElement", dom_attr_owner_element_read, NULL);
|
DOM_REGISTER_PROP_HANDLER(&dom_modern_attr_prop_handlers, "ownerElement", dom_attr_owner_element_read, NULL);
|
||||||
DOM_REGISTER_PROP_HANDLER(&dom_modern_attr_prop_handlers, "specified", dom_attr_specified_read, NULL);
|
DOM_REGISTER_PROP_HANDLER(&dom_modern_attr_prop_handlers, "specified", dom_attr_specified_read, NULL);
|
||||||
zend_hash_merge(&dom_modern_attr_prop_handlers, &dom_node_prop_handlers, NULL, false);
|
zend_hash_merge(&dom_modern_attr_prop_handlers, &dom_modern_node_prop_handlers, NULL, false);
|
||||||
DOM_OVERWRITE_PROP_HANDLER(&dom_modern_attr_prop_handlers, "nodeValue", dom_node_node_value_read, dom_node_node_value_write);
|
DOM_OVERWRITE_PROP_HANDLER(&dom_modern_attr_prop_handlers, "nodeValue", dom_node_node_value_read, dom_node_node_value_write);
|
||||||
DOM_OVERWRITE_PROP_HANDLER(&dom_modern_attr_prop_handlers, "textContent", dom_node_text_content_read, dom_node_text_content_write);
|
DOM_OVERWRITE_PROP_HANDLER(&dom_modern_attr_prop_handlers, "textContent", dom_node_text_content_read, dom_node_text_content_write);
|
||||||
zend_hash_add_new_ptr(&classes, dom_modern_attr_class_entry->name, &dom_modern_attr_prop_handlers);
|
zend_hash_add_new_ptr(&classes, dom_modern_attr_class_entry->name, &dom_modern_attr_prop_handlers);
|
||||||
|
@ -1194,7 +1194,7 @@ PHP_MINIT_FUNCTION(dom)
|
||||||
DOM_REGISTER_PROP_HANDLER(&dom_modern_documenttype_prop_handlers, "publicId", dom_documenttype_public_id_read, NULL);
|
DOM_REGISTER_PROP_HANDLER(&dom_modern_documenttype_prop_handlers, "publicId", dom_documenttype_public_id_read, NULL);
|
||||||
DOM_REGISTER_PROP_HANDLER(&dom_modern_documenttype_prop_handlers, "systemId", dom_documenttype_system_id_read, NULL);
|
DOM_REGISTER_PROP_HANDLER(&dom_modern_documenttype_prop_handlers, "systemId", dom_documenttype_system_id_read, NULL);
|
||||||
DOM_REGISTER_PROP_HANDLER(&dom_modern_documenttype_prop_handlers, "internalSubset", dom_documenttype_internal_subset_read, NULL);
|
DOM_REGISTER_PROP_HANDLER(&dom_modern_documenttype_prop_handlers, "internalSubset", dom_documenttype_internal_subset_read, NULL);
|
||||||
zend_hash_merge(&dom_modern_documenttype_prop_handlers, &dom_node_prop_handlers, NULL, false);
|
zend_hash_merge(&dom_modern_documenttype_prop_handlers, &dom_modern_node_prop_handlers, NULL, false);
|
||||||
zend_hash_add_new_ptr(&classes, dom_modern_documenttype_class_entry->name, &dom_modern_documenttype_prop_handlers);
|
zend_hash_add_new_ptr(&classes, dom_modern_documenttype_class_entry->name, &dom_modern_documenttype_prop_handlers);
|
||||||
|
|
||||||
dom_notation_class_entry = register_class_DOMNotation(dom_node_class_entry);
|
dom_notation_class_entry = register_class_DOMNotation(dom_node_class_entry);
|
||||||
|
|
16
ext/dom/tests/gh17397.phpt
Normal file
16
ext/dom/tests/gh17397.phpt
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
--TEST--
|
||||||
|
GH-17397 (Assertion failure ext/dom/php_dom.c)
|
||||||
|
--EXTENSIONS--
|
||||||
|
dom
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$dom = Dom\HTMLDocument::createFromString('<!DOCTYPE html><html></html>');
|
||||||
|
var_dump($dom->doctype->prefix);
|
||||||
|
echo $dom->saveXml();
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
Warning: Undefined property: Dom\DocumentType::$prefix in %s on line %d
|
||||||
|
NULL
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body></body></html>
|
|
@ -25,7 +25,7 @@ foreach ($test_matrix as $test_item) {
|
||||||
|
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
object(Dom\DocumentType)#3 (23) {
|
object(Dom\DocumentType)#3 (19) {
|
||||||
["name"]=>
|
["name"]=>
|
||||||
string(5) "qname"
|
string(5) "qname"
|
||||||
["entities"]=>
|
["entities"]=>
|
||||||
|
@ -38,12 +38,14 @@ object(Dom\DocumentType)#3 (23) {
|
||||||
string(6) "system"
|
string(6) "system"
|
||||||
["internalSubset"]=>
|
["internalSubset"]=>
|
||||||
NULL
|
NULL
|
||||||
["nodeName"]=>
|
|
||||||
string(5) "qname"
|
|
||||||
["nodeValue"]=>
|
|
||||||
NULL
|
|
||||||
["nodeType"]=>
|
["nodeType"]=>
|
||||||
int(10)
|
int(10)
|
||||||
|
["nodeName"]=>
|
||||||
|
string(5) "qname"
|
||||||
|
["baseURI"]=>
|
||||||
|
NULL
|
||||||
|
["isConnected"]=>
|
||||||
|
bool(false)
|
||||||
["parentNode"]=>
|
["parentNode"]=>
|
||||||
NULL
|
NULL
|
||||||
["parentElement"]=>
|
["parentElement"]=>
|
||||||
|
@ -58,17 +60,7 @@ object(Dom\DocumentType)#3 (23) {
|
||||||
NULL
|
NULL
|
||||||
["nextSibling"]=>
|
["nextSibling"]=>
|
||||||
NULL
|
NULL
|
||||||
["attributes"]=>
|
["nodeValue"]=>
|
||||||
NULL
|
|
||||||
["isConnected"]=>
|
|
||||||
bool(false)
|
|
||||||
["namespaceURI"]=>
|
|
||||||
NULL
|
|
||||||
["prefix"]=>
|
|
||||||
string(0) ""
|
|
||||||
["localName"]=>
|
|
||||||
NULL
|
|
||||||
["baseURI"]=>
|
|
||||||
NULL
|
NULL
|
||||||
["textContent"]=>
|
["textContent"]=>
|
||||||
string(0) ""
|
string(0) ""
|
||||||
|
@ -76,7 +68,7 @@ object(Dom\DocumentType)#3 (23) {
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE qname PUBLIC "public" "system">
|
<!DOCTYPE qname PUBLIC "public" "system">
|
||||||
|
|
||||||
object(Dom\DocumentType)#2 (23) {
|
object(Dom\DocumentType)#2 (19) {
|
||||||
["name"]=>
|
["name"]=>
|
||||||
string(5) "qname"
|
string(5) "qname"
|
||||||
["entities"]=>
|
["entities"]=>
|
||||||
|
@ -89,12 +81,14 @@ object(Dom\DocumentType)#2 (23) {
|
||||||
string(0) ""
|
string(0) ""
|
||||||
["internalSubset"]=>
|
["internalSubset"]=>
|
||||||
NULL
|
NULL
|
||||||
["nodeName"]=>
|
|
||||||
string(5) "qname"
|
|
||||||
["nodeValue"]=>
|
|
||||||
NULL
|
|
||||||
["nodeType"]=>
|
["nodeType"]=>
|
||||||
int(10)
|
int(10)
|
||||||
|
["nodeName"]=>
|
||||||
|
string(5) "qname"
|
||||||
|
["baseURI"]=>
|
||||||
|
NULL
|
||||||
|
["isConnected"]=>
|
||||||
|
bool(false)
|
||||||
["parentNode"]=>
|
["parentNode"]=>
|
||||||
NULL
|
NULL
|
||||||
["parentElement"]=>
|
["parentElement"]=>
|
||||||
|
@ -109,17 +103,7 @@ object(Dom\DocumentType)#2 (23) {
|
||||||
NULL
|
NULL
|
||||||
["nextSibling"]=>
|
["nextSibling"]=>
|
||||||
NULL
|
NULL
|
||||||
["attributes"]=>
|
["nodeValue"]=>
|
||||||
NULL
|
|
||||||
["isConnected"]=>
|
|
||||||
bool(false)
|
|
||||||
["namespaceURI"]=>
|
|
||||||
NULL
|
|
||||||
["prefix"]=>
|
|
||||||
string(0) ""
|
|
||||||
["localName"]=>
|
|
||||||
NULL
|
|
||||||
["baseURI"]=>
|
|
||||||
NULL
|
NULL
|
||||||
["textContent"]=>
|
["textContent"]=>
|
||||||
string(0) ""
|
string(0) ""
|
||||||
|
@ -127,7 +111,7 @@ object(Dom\DocumentType)#2 (23) {
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE qname PUBLIC "public" "">
|
<!DOCTYPE qname PUBLIC "public" "">
|
||||||
|
|
||||||
object(Dom\DocumentType)#1 (23) {
|
object(Dom\DocumentType)#1 (19) {
|
||||||
["name"]=>
|
["name"]=>
|
||||||
string(5) "qname"
|
string(5) "qname"
|
||||||
["entities"]=>
|
["entities"]=>
|
||||||
|
@ -140,12 +124,14 @@ object(Dom\DocumentType)#1 (23) {
|
||||||
string(6) "system"
|
string(6) "system"
|
||||||
["internalSubset"]=>
|
["internalSubset"]=>
|
||||||
NULL
|
NULL
|
||||||
["nodeName"]=>
|
|
||||||
string(5) "qname"
|
|
||||||
["nodeValue"]=>
|
|
||||||
NULL
|
|
||||||
["nodeType"]=>
|
["nodeType"]=>
|
||||||
int(10)
|
int(10)
|
||||||
|
["nodeName"]=>
|
||||||
|
string(5) "qname"
|
||||||
|
["baseURI"]=>
|
||||||
|
NULL
|
||||||
|
["isConnected"]=>
|
||||||
|
bool(false)
|
||||||
["parentNode"]=>
|
["parentNode"]=>
|
||||||
NULL
|
NULL
|
||||||
["parentElement"]=>
|
["parentElement"]=>
|
||||||
|
@ -160,17 +146,7 @@ object(Dom\DocumentType)#1 (23) {
|
||||||
NULL
|
NULL
|
||||||
["nextSibling"]=>
|
["nextSibling"]=>
|
||||||
NULL
|
NULL
|
||||||
["attributes"]=>
|
["nodeValue"]=>
|
||||||
NULL
|
|
||||||
["isConnected"]=>
|
|
||||||
bool(false)
|
|
||||||
["namespaceURI"]=>
|
|
||||||
NULL
|
|
||||||
["prefix"]=>
|
|
||||||
string(0) ""
|
|
||||||
["localName"]=>
|
|
||||||
NULL
|
|
||||||
["baseURI"]=>
|
|
||||||
NULL
|
NULL
|
||||||
["textContent"]=>
|
["textContent"]=>
|
||||||
string(0) ""
|
string(0) ""
|
||||||
|
@ -178,7 +154,7 @@ object(Dom\DocumentType)#1 (23) {
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE qname SYSTEM "system">
|
<!DOCTYPE qname SYSTEM "system">
|
||||||
|
|
||||||
object(Dom\DocumentType)#4 (23) {
|
object(Dom\DocumentType)#4 (19) {
|
||||||
["name"]=>
|
["name"]=>
|
||||||
string(5) "qname"
|
string(5) "qname"
|
||||||
["entities"]=>
|
["entities"]=>
|
||||||
|
@ -191,12 +167,14 @@ object(Dom\DocumentType)#4 (23) {
|
||||||
string(0) ""
|
string(0) ""
|
||||||
["internalSubset"]=>
|
["internalSubset"]=>
|
||||||
NULL
|
NULL
|
||||||
["nodeName"]=>
|
|
||||||
string(5) "qname"
|
|
||||||
["nodeValue"]=>
|
|
||||||
NULL
|
|
||||||
["nodeType"]=>
|
["nodeType"]=>
|
||||||
int(10)
|
int(10)
|
||||||
|
["nodeName"]=>
|
||||||
|
string(5) "qname"
|
||||||
|
["baseURI"]=>
|
||||||
|
NULL
|
||||||
|
["isConnected"]=>
|
||||||
|
bool(false)
|
||||||
["parentNode"]=>
|
["parentNode"]=>
|
||||||
NULL
|
NULL
|
||||||
["parentElement"]=>
|
["parentElement"]=>
|
||||||
|
@ -211,17 +189,7 @@ object(Dom\DocumentType)#4 (23) {
|
||||||
NULL
|
NULL
|
||||||
["nextSibling"]=>
|
["nextSibling"]=>
|
||||||
NULL
|
NULL
|
||||||
["attributes"]=>
|
["nodeValue"]=>
|
||||||
NULL
|
|
||||||
["isConnected"]=>
|
|
||||||
bool(false)
|
|
||||||
["namespaceURI"]=>
|
|
||||||
NULL
|
|
||||||
["prefix"]=>
|
|
||||||
string(0) ""
|
|
||||||
["localName"]=>
|
|
||||||
NULL
|
|
||||||
["baseURI"]=>
|
|
||||||
NULL
|
NULL
|
||||||
["textContent"]=>
|
["textContent"]=>
|
||||||
string(0) ""
|
string(0) ""
|
||||||
|
|
|
@ -26,7 +26,7 @@ var_dump($doctype->notations["GIF"]);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--EXPECTF--
|
||||||
object(Dom\DocumentType)#2 (24) {
|
object(Dom\DocumentType)#2 (20) {
|
||||||
["name"]=>
|
["name"]=>
|
||||||
string(4) "root"
|
string(4) "root"
|
||||||
["entities"]=>
|
["entities"]=>
|
||||||
|
@ -41,12 +41,16 @@ object(Dom\DocumentType)#2 (24) {
|
||||||
string(105) "<!ENTITY test "entity is only for test purposes">
|
string(105) "<!ENTITY test "entity is only for test purposes">
|
||||||
<!ENTITY myimage PUBLIC "-" "mypicture.gif" NDATA GIF>
|
<!ENTITY myimage PUBLIC "-" "mypicture.gif" NDATA GIF>
|
||||||
"
|
"
|
||||||
["nodeName"]=>
|
|
||||||
string(4) "root"
|
|
||||||
["nodeValue"]=>
|
|
||||||
NULL
|
|
||||||
["nodeType"]=>
|
["nodeType"]=>
|
||||||
int(10)
|
int(10)
|
||||||
|
["nodeName"]=>
|
||||||
|
string(4) "root"
|
||||||
|
["baseURI"]=>
|
||||||
|
string(%d) "%s"
|
||||||
|
["isConnected"]=>
|
||||||
|
bool(true)
|
||||||
|
["ownerDocument"]=>
|
||||||
|
string(22) "(object value omitted)"
|
||||||
["parentNode"]=>
|
["parentNode"]=>
|
||||||
string(22) "(object value omitted)"
|
string(22) "(object value omitted)"
|
||||||
["parentElement"]=>
|
["parentElement"]=>
|
||||||
|
@ -61,20 +65,8 @@ object(Dom\DocumentType)#2 (24) {
|
||||||
NULL
|
NULL
|
||||||
["nextSibling"]=>
|
["nextSibling"]=>
|
||||||
string(22) "(object value omitted)"
|
string(22) "(object value omitted)"
|
||||||
["attributes"]=>
|
["nodeValue"]=>
|
||||||
NULL
|
NULL
|
||||||
["isConnected"]=>
|
|
||||||
bool(true)
|
|
||||||
["ownerDocument"]=>
|
|
||||||
string(22) "(object value omitted)"
|
|
||||||
["namespaceURI"]=>
|
|
||||||
NULL
|
|
||||||
["prefix"]=>
|
|
||||||
string(0) ""
|
|
||||||
["localName"]=>
|
|
||||||
NULL
|
|
||||||
["baseURI"]=>
|
|
||||||
string(%d) "%s"
|
|
||||||
["textContent"]=>
|
["textContent"]=>
|
||||||
NULL
|
NULL
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue