From 318f5c93737b126ac4ecaf425f4ce019cadde742 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Tue, 2 Jan 2018 15:48:16 +0100 Subject: [PATCH] URLs without a seperate label could end up being empty --- .../converter/UrlMetacodeConverter.class.php | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/wcfsetup/install/files/lib/system/html/metacode/converter/UrlMetacodeConverter.class.php b/wcfsetup/install/files/lib/system/html/metacode/converter/UrlMetacodeConverter.class.php index c8cf5682d5..5d1f195fce 100644 --- a/wcfsetup/install/files/lib/system/html/metacode/converter/UrlMetacodeConverter.class.php +++ b/wcfsetup/install/files/lib/system/html/metacode/converter/UrlMetacodeConverter.class.php @@ -1,5 +1,6 @@ `. @@ -22,6 +23,26 @@ class UrlMetacodeConverter extends AbstractMetacodeConverter { $href = $fragment->textContent; } + // check if the link is empty, use the href value instead + $useHrefAsValue = false; + if ($fragment->childNodes->length === 0) { + $useHrefAsValue = true; + } + else if ($fragment->childNodes->length === 1) { + $node = $fragment->childNodes->item(0); + if ($node->nodeType === XML_TEXT_NODE && StringUtil::trim($node->textContent) === '') { + $useHrefAsValue = true; + } + } + + if ($useHrefAsValue) { + if ($fragment->childNodes->length === 1) { + $fragment->removeChild($fragment->childNodes->item(0)); + } + + $fragment->appendChild($fragment->ownerDocument->createTextNode($href)); + } + $element->setAttribute('href', $href); $element->appendChild($fragment); -- 2.20.1