From cfbc13442befc432291bf905ea4e2a75ffca6b7d Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 26 Sep 2016 00:33:59 +0200 Subject: [PATCH] Properly handling destructed nodes --- .../node/HtmlInputNodeWoltlabMetacode.class.php | 2 +- wcfsetup/install/files/lib/util/DOMUtil.class.php | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeWoltlabMetacode.class.php b/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeWoltlabMetacode.class.php index 4c67812b78..f19b72fdc9 100644 --- a/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeWoltlabMetacode.class.php +++ b/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeWoltlabMetacode.class.php @@ -66,7 +66,7 @@ class HtmlInputNodeWoltlabMetacode extends AbstractHtmlInputNode { /** @var \DOMElement $element */ foreach ($elements as $element) { - if ($element->parentNode === null) { + if (DOMUtil::isRemoved($element) || $element->parentNode === null) { // ignore elements that existed, but have been removed // from the DOM due to action taken by a converter continue; diff --git a/wcfsetup/install/files/lib/util/DOMUtil.class.php b/wcfsetup/install/files/lib/util/DOMUtil.class.php index 6422c05dc5..17d434a27f 100644 --- a/wcfsetup/install/files/lib/util/DOMUtil.class.php +++ b/wcfsetup/install/files/lib/util/DOMUtil.class.php @@ -310,6 +310,18 @@ final class DOMUtil { return false; } + /** + * Nodes can get partially destroyed in which they're still an + * actual DOM node (such as \DOMElement) but almost their entire + * body is gone, including the `nodeType` attribute. + * + * @param \DOMNode $node node + * @return boolean true if node has been destroyed + */ + public static function isRemoved(\DOMNode $node) { + return !isset($node->nodeType); + } + /** * Returns true if provided element is a void element. Void elements are elements * that neither contain content nor have a closing tag, such as `
`. -- 2.20.1