Applied suggestions
authorMarcel Werk <burntime@woltlab.com>
Fri, 7 Aug 2020 10:11:10 +0000 (12:11 +0200)
committerMarcel Werk <burntime@woltlab.com>
Fri, 7 Aug 2020 10:11:10 +0000 (12:11 +0200)
wcfsetup/install/files/lib/data/article/content/ArticleContent.class.php
wcfsetup/install/files/lib/data/box/content/BoxContent.class.php
wcfsetup/install/files/lib/data/page/content/PageContent.class.php
wcfsetup/install/files/lib/system/html/output/HtmlOutputProcessor.class.php
wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeA.class.php
wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeImg.class.php
wcfsetup/install/files/lib/system/template/plugin/AnchorAttributesFunctionTemplatePlugin.class.php

index b2b200597ab855530620908df287d9b8658e499e..1fcdfd9fd0232df45225dda60156acf96bddc828 100644 (file)
@@ -81,7 +81,7 @@ class ArticleContent extends DatabaseObject implements ILinkableObject, IRouteCo
                else {
                        $htmlOutputProcessor = new HtmlOutputProcessor();
                        $htmlOutputProcessor->setOutputType('text/plain');
-                       $htmlOutputProcessor->setUgc(false);
+                       $htmlOutputProcessor->enableUgc = false;
                        $htmlOutputProcessor->process($this->content, 'com.woltlab.wcf.article.content', $this->articleContentID, false, $this->languageID);
                        
                        return nl2br(StringUtil::encodeHTML(StringUtil::truncate($htmlOutputProcessor->getHtml(), 500)), false);
@@ -95,7 +95,7 @@ class ArticleContent extends DatabaseObject implements ILinkableObject, IRouteCo
         */
        public function getFormattedContent() {
                $processor = new HtmlOutputProcessor();
-               $processor->setUgc(false);
+               $processor->enableUgc = false;
                $processor->process($this->content, 'com.woltlab.wcf.article.content', $this->articleContentID, false, $this->languageID);
                
                return $processor->getHtml();
@@ -108,7 +108,7 @@ class ArticleContent extends DatabaseObject implements ILinkableObject, IRouteCo
         */
        public function getAmpFormattedContent() {
                $processor = new AmpHtmlOutputProcessor();
-               $processor->setUgc(false);
+               $processor->enableUgc = false;
                $processor->process($this->content, 'com.woltlab.wcf.article.content', $this->articleContentID);
                
                return $processor->getHtml();
@@ -152,7 +152,7 @@ class ArticleContent extends DatabaseObject implements ILinkableObject, IRouteCo
                        case 'text/plain':
                                $processor = new HtmlOutputProcessor();
                                $processor->setOutputType('text/plain');
-                               $processor->setUgc(false);
+                               $processor->enableUgc = false;
                                $processor->process($this->content, 'com.woltlab.wcf.article.content', $this->articleContentID);
                                
                                return $processor->getHtml();
@@ -160,7 +160,7 @@ class ArticleContent extends DatabaseObject implements ILinkableObject, IRouteCo
                                // parse and return message
                                $processor = new HtmlOutputProcessor();
                                $processor->setOutputType('text/simplified-html');
-                               $processor->setUgc(false);
+                               $processor->enableUgc = false;
                                $processor->process($this->content, 'com.woltlab.wcf.article.content', $this->articleContentID);
                                
                                return $processor->getHtml();
index 29b055fa50f029faf1e5d0b850cce3395c256a79..eb46f3b1bb4bbb2c7b6d24209277c97a213c8070 100644 (file)
@@ -103,7 +103,7 @@ class BoxContent extends DatabaseObject {
         */
        public function getFormattedContent() {
                $processor = new HtmlOutputProcessor();
-               $processor->setUgc(false);
+               $processor->enableUgc = false;
                $processor->process($this->content, 'com.woltlab.wcf.box.content', $this->boxContentID);
                
                return $processor->getHtml();
index 956559b1ad722d5b2a930557d54f90f459afa286..95a22998266fe55e23aec792304559ff3f959c31 100644 (file)
@@ -47,7 +47,7 @@ class PageContent extends DatabaseObject implements ILinkableObject {
                MessageEmbeddedObjectManager::getInstance()->loadObjects('com.woltlab.wcf.page.content', [$this->pageContentID]);
                
                $processor = new HtmlOutputProcessor();
-               $processor->setUgc(false);
+               $processor->enableUgc = false;
                $processor->process($this->content, 'com.woltlab.wcf.page.content', $this->pageContentID);
                
                return $processor->getHtml();
index 6264184058597679a38ad7c90a6c4f31f5c6d2c6..0a6a1296f8f81320d8361806a2207cbcda2a6c4c 100644 (file)
@@ -51,7 +51,7 @@ class HtmlOutputProcessor extends AbstractHtmlProcessor {
         * enables rel=ugc for external links
         * @var bool
         */
-       protected $ugc = true;
+       public $enableUgc = true;
        
        /**
         * Processes the input html string.
@@ -119,22 +119,4 @@ class HtmlOutputProcessor extends AbstractHtmlProcessor {
                
                return $this->htmlOutputNodeProcessor;
        }
-       
-       /**
-        * Enables rel=ugc for external links.
-        * 
-        * @param bool $enable
-        */
-       public function setUgc($enable = true) {
-               $this->ugc = $enable;
-       }
-       
-       /**
-        * Returns true, if content is user-generated.
-        * 
-        * @return bool
-        */
-       public function isUgc() {
-               return $this->ugc;
-       }
 }
index 9ec37e7af682eda98fb23b321fd78dcf90a0f976..9ddc5dcebb5b1505d24e5a8308505b59a80682e9 100644 (file)
@@ -33,7 +33,7 @@ class HtmlOutputNodeA extends AbstractHtmlOutputNode {
                        }
                        else {
                                /** @var HtmlOutputNodeProcessor $htmlNodeProcessor */
-                               self::markLinkAsExternal($element, $htmlNodeProcessor->getHtmlProcessor()->isUgc());
+                               self::markLinkAsExternal($element, $htmlNodeProcessor->getHtmlProcessor()->enableUgc);
                        }
                        
                        $value = StringUtil::trim($element->textContent);
index 0b9fa6ca41076904713e33ee1ac87c544084df48..d03f0c1137b84f9bf3d31cabc255d4c1d7f02ee0 100644 (file)
@@ -86,7 +86,7 @@ class HtmlOutputNodeImg extends AbstractHtmlOutputNode {
                                                // proxy is enabled for insecure connections only
                                                if (!IMAGE_ALLOW_EXTERNAL_SOURCE && !$this->isAllowedOrigin($src)) {
                                                        /** @var HtmlOutputNodeProcessor $htmlNodeProcessor */
-                                                       $this->replaceExternalSource($element, $src, $htmlNodeProcessor->getHtmlProcessor()->isUgc());
+                                                       $this->replaceExternalSource($element, $src, $htmlNodeProcessor->getHtmlProcessor()->enableUgc);
                                                }
                                                
                                                continue;
@@ -135,7 +135,7 @@ class HtmlOutputNodeImg extends AbstractHtmlOutputNode {
                                }
                                else if (!IMAGE_ALLOW_EXTERNAL_SOURCE && !$this->isAllowedOrigin($src)) {
                                        /** @var HtmlOutputNodeProcessor $htmlNodeProcessor */
-                                       $this->replaceExternalSource($element, $src, $htmlNodeProcessor->getHtmlProcessor()->isUgc());
+                                       $this->replaceExternalSource($element, $src, $htmlNodeProcessor->getHtmlProcessor()->enableUgc);
                                }
                                else if (MESSAGE_FORCE_SECURE_IMAGES && Url::parse($src)['scheme'] === 'http') {
                                        // rewrite protocol to `https`
index 554816513562b604c1d0bf436f8b9a59ab5d12ac..5ec59f33cd908f135454644500dea7edec1b0762 100644 (file)
@@ -45,7 +45,7 @@ class AnchorAttributesFunctionTemplatePlugin implements IFunctionTemplatePlugin
                
                $attributes = '';
                if ($appendHref) {
-                       $attributes = 'href="' . StringUtil::encodeHTML($url) . '"';
+                       $attributes .= ' href="' . StringUtil::encodeHTML($url) . '"';
                }
                
                if ($external) {