Removed quotes from quoted messages
authorAlexander Ebert <ebert@woltlab.com>
Fri, 19 Aug 2016 13:08:04 +0000 (15:08 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 19 Aug 2016 13:56:29 +0000 (15:56 +0200)
wcfsetup/install/files/lib/system/html/input/HtmlInputProcessor.class.php
wcfsetup/install/files/lib/system/message/quote/MessageQuoteManager.class.php

index 478317c333f387fe271983f1fcf057114138de2c..d916646b5dc66ddd190c41a6c190df7bf59382eb 100644 (file)
@@ -64,6 +64,17 @@ class HtmlInputProcessor extends AbstractHtmlProcessor {
                $this->embeddedContent = $this->getHtmlInputNodeProcessor()->getEmbeddedContent();
        }
        
+       /**
+        * Processes a HTML string to provide the general DOM API. This method
+        * does not perform any filtering or validation. You SHOULD NOT use this
+        * to deal with HTML that has not been filtered previously.
+        * 
+        * @param       string          $html   html string
+        */
+       public function processIntermediate($html) {
+               $this->getHtmlInputNodeProcessor()->load($this, $html);
+       }
+       
        /**
         * Processes only embedded content. This method should only be called when rebuilding
         * data where only embedded content is relevant, but no actual parsing is required.
index 702a3a750b2b440882288e2e667bc5d11ad92d10..163f9f018ca1f69d64041e234b2d75a23f947e78 100644 (file)
@@ -4,9 +4,11 @@ use wcf\data\object\type\ObjectType;
 use wcf\data\object\type\ObjectTypeCache;
 use wcf\data\IMessage;
 use wcf\system\exception\SystemException;
+use wcf\system\html\input\HtmlInputProcessor;
 use wcf\system\SingletonFactory;
 use wcf\system\WCF;
 use wcf\util\ArrayUtil;
+use wcf\util\DOMUtil;
 
 /**
  * Manages message quotes.
@@ -128,8 +130,17 @@ class MessageQuoteManager extends SingletonFactory {
                        $this->quoteData[$quoteID.'_pID'] = $parentObjectID;
                        
                        if (!empty($fullQuote)) {
+                               // strip quotes container in full quote
+                               $htmlInputProcessor = new HtmlInputProcessor();
+                               $htmlInputProcessor->processIntermediate($fullQuote);
+                               
+                               $elements = $htmlInputProcessor->getHtmlInputNodeProcessor()->getDocument()->getElementsByTagName('blockquote');
+                               while ($elements->length) {
+                                       DOMUtil::removeNode($elements->item(0));
+                               }
+                               
                                $this->quotes[$objectType][$objectID][$quoteID] = 1;
-                               $this->quoteData[$quoteID.'_fq'] = $fullQuote;
+                               $this->quoteData[$quoteID.'_fq'] = $htmlInputProcessor->getHtml();
                        }
                        
                        $this->updateSession();