From 80a0751b8ec63afb5df74ec6b56200197e1568ad Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Thu, 21 Mar 2019 19:57:22 +0100 Subject: [PATCH] Remove HTML links from the output on request --- .../lib/system/html/output/HtmlOutputProcessor.class.php | 7 +++++++ .../html/output/node/HtmlOutputNodeProcessor.class.php | 7 +++++++ 2 files changed, 14 insertions(+) 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'); -- 2.20.1