Remove HTML links from the output on request
authorAlexander Ebert <ebert@woltlab.com>
Thu, 21 Mar 2019 18:57:22 +0000 (19:57 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 21 Mar 2019 18:57:22 +0000 (19:57 +0100)
wcfsetup/install/files/lib/system/html/output/HtmlOutputProcessor.class.php
wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeProcessor.class.php

index bc95c8402687b6ada5937d92fb0a31ea7a3a01c9..37856c01ec730902273368a9615f773b3597e742 100644 (file)
@@ -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
index 98177f87a8069d5f3e01f4a70fc0d1249507ac8f..65eca5bca4cead619c2ce290b6db17155d60ecc0 100644 (file)
@@ -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 `<p>...</p>` into `...<br><br>`
                        $paragraphs = $this->getDocument()->getElementsByTagName('p');