From: Alexander Ebert Date: Thu, 11 Aug 2016 20:11:46 +0000 (+0200) Subject: Preventing trailing
X-Git-Tag: 3.0.0_Beta_1~768 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=29e75823ae406e809e0be0ec5348cfc0c5a9a85a;p=GitHub%2FWoltLab%2FWCF.git Preventing trailing
--- 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);