From a8793d6e848cdafab80f0c8e42a273fafb405825 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Wed, 21 Dec 2016 09:42:17 +0100 Subject: [PATCH] `nodeValue` trips over entities when used w/ elements --- .../listener/AbstractHtmlInputNodeProcessorListener.class.php | 3 ++- .../system/html/input/node/HtmlInputNodeTextParser.class.php | 2 +- .../html/metacode/converter/CodeMetacodeConverter.class.php | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/wcfsetup/install/files/lib/system/event/listener/AbstractHtmlInputNodeProcessorListener.class.php b/wcfsetup/install/files/lib/system/event/listener/AbstractHtmlInputNodeProcessorListener.class.php index 4078e8cf4e..41c06eadcd 100644 --- a/wcfsetup/install/files/lib/system/event/listener/AbstractHtmlInputNodeProcessorListener.class.php +++ b/wcfsetup/install/files/lib/system/event/listener/AbstractHtmlInputNodeProcessorListener.class.php @@ -100,7 +100,8 @@ abstract class AbstractHtmlInputNodeProcessorListener implements IParameterizedE throw new ImplementationException(get_class($object), ITitledObject::class); } - $element->nodeValue = $object->getTitle(); + $element->nodeValue = ''; + $element->appendChild($element->ownerDocument->createTextNode($object->getTitle())); } } } diff --git a/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeTextParser.class.php b/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeTextParser.class.php index 320c464caf..dd4e836f8f 100644 --- a/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeTextParser.class.php +++ b/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeTextParser.class.php @@ -393,7 +393,7 @@ class HtmlInputNodeTextParser { $element = $text->ownerDocument->createElement('a'); $element->setAttribute('href', $link); - $element->nodeValue = $link; + $element->appendChild($element->ownerDocument->createTextNode($link)); } else { return $matches[0]; diff --git a/wcfsetup/install/files/lib/system/html/metacode/converter/CodeMetacodeConverter.class.php b/wcfsetup/install/files/lib/system/html/metacode/converter/CodeMetacodeConverter.class.php index 632b31859b..911143f8aa 100644 --- a/wcfsetup/install/files/lib/system/html/metacode/converter/CodeMetacodeConverter.class.php +++ b/wcfsetup/install/files/lib/system/html/metacode/converter/CodeMetacodeConverter.class.php @@ -100,7 +100,9 @@ class CodeMetacodeConverter extends AbstractMetacodeConverter { } // trim code block - $element->nodeValue = StringUtil::trim($element->textContent); + $content = StringUtil::trim($element->textContent); + $element->nodeValue = ''; + $element->appendChild($element->ownerDocument->createTextNode($content)); return $element; } -- 2.20.1