From 29e75823ae406e809e0be0ec5348cfc0c5a9a85a Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Thu, 11 Aug 2016 22:11:46 +0200 Subject: [PATCH] Preventing trailing
--- .../node/HtmlOutputNodeProcessor.class.php | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeProcessor.class.php b/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeProcessor.class.php index b34e21f657..c3402703c2 100644 --- a/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeProcessor.class.php +++ b/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeProcessor.class.php @@ -50,9 +50,28 @@ class HtmlOutputNodeProcessor extends AbstractHtmlNodeProcessor { while ($paragraphs->length) { $paragraph = $paragraphs->item(0); - for ($i = 0; $i < 2; $i++) { - $br = $this->getDocument()->createElement('br'); - $paragraph->appendChild($br); + $isLastNode = true; + $sibling = $paragraph; + while ($sibling = $sibling->nextSibling) { + if ($sibling->nodeType === XML_ELEMENT_NODE) { + if ($sibling->nodeName !== 'br') { + $isLastNode = false; + break; + } + } + else if ($sibling->nodeType === XML_TEXT_NODE) { + if (StringUtil::trim($sibling->textContent) !== '') { + $isLastNode = false; + break; + } + } + } + + if (!$isLastNode) { + for ($i = 0; $i < 2; $i++) { + $br = $this->getDocument()->createElement('br'); + $paragraph->appendChild($br); + } } DOMUtil::removeNode($paragraph, true); -- 2.20.1