From a9a5a68a1cb685a6f441dd8d20339db29326b187 Mon Sep 17 00:00:00 2001 From: Robert Kaiser Date: Thu, 15 Dec 2016 22:59:12 +0100 Subject: [PATCH] replace workaround for HTML markup with a sane way of doing it, via loadHTML() --- classes/document.php-class | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/classes/document.php-class b/classes/document.php-class index 3e39f0a..dbad743 100755 --- a/classes/document.php-class +++ b/classes/document.php-class @@ -299,8 +299,13 @@ class ExtendedDocument extends DOMDocument { public function appendHTMLMarkup($htmldata, $parentNode = null) { if (is_null($parentNode)) { $parentNode =& $this; } - // XXX: just a workaround for now! - $parentNode->appendChild($this->createCDATASection($htmldata)); + // Use loadHTML() to parse and turn the markup into proper HTML. + $tmpdoc = new ExtendedDocument; + // The XML line is needed to tell the parser that we need UTF-8 parsing. + $tmpdoc->loadHTML(''.$htmldata.''); + foreach ($tmpdoc->getElementsByTagName('body')->item(0)->childNodes as $child) { + $parentNode->appendChild($this->importNode($child, true)); + } } public function appendXMLMarkup($xmldata, $parentNode = null) { -- 2.35.3