Fix markup for linked, blocked images in UGC
authorTim Düsterhus <duesterhus@woltlab.com>
Fri, 3 Jul 2020 13:10:38 +0000 (15:10 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Fri, 3 Jul 2020 13:11:47 +0000 (15:11 +0200)
Fixes #3384

wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeImg.class.php

index b5ce8e141a2c40497586b5f4d1cc87fffe5f3b87..362bdb4176d59e494c7340b000b0347d059ce59e 100644 (file)
@@ -152,10 +152,15 @@ class HtmlOutputNodeImg extends AbstractHtmlOutputNode {
        protected function replaceExternalSource(\DOMElement $element, $src) {
                $element->parentNode->insertBefore($element->ownerDocument->createTextNode('['.WCF::getLanguage()->get('wcf.bbcode.image.blocked').': '), $element);
                
-               $link = $element->ownerDocument->createElement('a');
-               $link->setAttribute('href', $src);
-               $link->textContent = $src;
-               HtmlOutputNodeA::markLinkAsExternal($link);
+               if (!DOMUtil::hasParent($element, 'a')) {
+                       $link = $element->ownerDocument->createElement('a');
+                       $link->setAttribute('href', $src);
+                       $link->textContent = $src;
+                       HtmlOutputNodeA::markLinkAsExternal($link);
+               }
+               else {
+                       $link = $element->ownerDocument->createTextNode($src);
+               }
                
                $element->parentNode->insertBefore($link, $element);