From a8816f4353d72c047dd754a9c4952e9a7c7ae99d Mon Sep 17 00:00:00 2001 From: Robert Kaiser Date: Sun, 2 Oct 2016 01:07:25 +0200 Subject: [PATCH] actually override createElement to support the escaping --- include/cbsm/util/document.php-class | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/include/cbsm/util/document.php-class b/include/cbsm/util/document.php-class index c64d9a4..d023c99 100755 --- a/include/cbsm/util/document.php-class +++ b/include/cbsm/util/document.php-class @@ -199,10 +199,7 @@ class ExtendedDocument extends DOMDocument { } function appendElement($name, $value = '') { - // Adding the $value in createElement does NOT escape it, so use appendText to support that. - $aelem = $this->appendChild($this->createElement($name)); - $aelem->appendText($value); - return $aelem; + return $this->appendChild($this->createElement($name, $value)); } function appendElementXML($name, $xmldata) { $aelem = $this->appendChild($this->createElement($name)); @@ -290,9 +287,15 @@ class ExtendedDocument extends DOMDocument { } } + function createElement($name, $value = '') { + // Adding the $value in DOMDocument's createElement does NOT escape it, so override it and use appendText to support that. + $aelem = parent::createElement($name); + $aelem->appendText($value); + return $aelem; + } + function createElementLink($target, $value = '') { - $link = $this->createElement('a'); - $link->appendText($value); + $link = $this->createElement('a', $value); $link->setAttribute('href', $target); // XXX: take care of & etc. in links return $link; } @@ -541,10 +544,7 @@ class ExtendedElement extends DOMElement { // returns the new child function appendElement($name, $value = '') { - // Adding the $value in createElement does NOT escape it, so use appendText to support that. - $aelem = $this->appendChild($this->ownerDocument->createElement($name)); - $aelem->appendText($value); - return $aelem; + return $this->appendChild($this->ownerDocument->createElement($name, $value)); } function appendElementXML($name, $xmldata) { $aelem = $this->appendChild($this->ownerDocument->createElement($name)); @@ -722,10 +722,7 @@ class ExtendedDocumentFragment extends DOMDocumentFragment { // returns the new child function appendElement($name, $value = '') { - // Adding the $value in createElement does NOT escape it, so use appendText to support that. - $aelem = $this->appendChild($this->ownerDocument->createElement($name)); - $aelem->appendText($value); - return $aelem; + return $this->appendChild($this->ownerDocument->createElement($name, $value)); } function appendElementXML($name, $xmldata) { $aelem = $this->appendChild($this->ownerDocument->createElement($name)); -- 2.43.0