Merge branch 'PHP-8.3'

* PHP-8.3:
  Fix crash when toggleAttribute() is used without a document
This commit is contained in:
Niels Dossche 2023-12-22 21:13:12 +01:00
commit 20dfc41053
2 changed files with 18 additions and 1 deletions

View file

@ -1555,7 +1555,7 @@ PHP_METHOD(DOMElement, toggleAttribute)
} }
/* Step 2 */ /* Step 2 */
if (thisp->doc->type == XML_HTML_DOCUMENT_NODE && (thisp->ns == NULL || xmlStrEqual(thisp->ns->href, (const xmlChar *) "http://www.w3.org/1999/xhtml"))) { if (thisp->doc != NULL && thisp->doc->type == XML_HTML_DOCUMENT_NODE && (thisp->ns == NULL || xmlStrEqual(thisp->ns->href, (const xmlChar *) "http://www.w3.org/1999/xhtml"))) {
qname_tmp = zend_str_tolower_dup_ex(qname, qname_length); qname_tmp = zend_str_tolower_dup_ex(qname, qname_length);
if (qname_tmp != NULL) { if (qname_tmp != NULL) {
qname = qname_tmp; qname = qname_tmp;

View file

@ -0,0 +1,17 @@
--TEST--
DOMElement::toggleAttribute() without a document
--EXTENSIONS--
dom
--FILE--
<?php
$element = new DOMElement("container");
$element->toggleAttribute('foo', true);
$dom = new DOMDocument;
$element = $dom->importNode($element, true);
echo $dom->saveXML($element), "\n";
?>
--EXPECT--
<container foo=""/>