From: Alexander Ebert Date: Thu, 21 Mar 2019 18:57:22 +0000 (+0100) Subject: Remove HTML links from the output on request X-Git-Tag: 5.2.0_Alpha_1~181^2~5 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=80a0751b8ec63afb5df74ec6b56200197e1568ad;p=GitHub%2FWoltLab%2FWCF.git Remove HTML links from the output on request --- diff --git a/wcfsetup/install/files/lib/system/html/output/HtmlOutputProcessor.class.php b/wcfsetup/install/files/lib/system/html/output/HtmlOutputProcessor.class.php index bc95c84026..37856c01ec 100644 --- a/wcfsetup/install/files/lib/system/html/output/HtmlOutputProcessor.class.php +++ b/wcfsetup/install/files/lib/system/html/output/HtmlOutputProcessor.class.php @@ -22,6 +22,13 @@ class HtmlOutputProcessor extends AbstractHtmlProcessor { */ public $enableToc = false; + /** + * Removes any link contained inside the message text. + * @var bool + * @since 5.2 + */ + public $removeLinks = false; + /** * output node processor instance * @var HtmlOutputNodeProcessor 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 98177f87a8..65eca5bca4 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 @@ -90,6 +90,13 @@ class HtmlOutputNodeProcessor extends AbstractHtmlNodeProcessor { // dynamic node handlers $this->invokeNodeHandlers('wcf\system\html\output\node\HtmlOutputNode', ['woltlab-metacode']); + if ($this->getHtmlProcessor()->removeLinks) { + $links = $this->getDocument()->getElementsByTagName('a'); + while ($links->length) { + DOMUtil::removeNode($links->item(0), true); + } + } + if ($this->outputType !== 'text/html') { // convert `

...

` into `...

` $paragraphs = $this->getDocument()->getElementsByTagName('p');