Add censorship enforement for WSYIWYG form builder fields
authorMatthias Schmidt <gravatronics@live.com>
Sat, 17 Aug 2019 12:25:08 +0000 (14:25 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Sat, 17 Aug 2019 12:25:08 +0000 (14:25 +0200)
See #3022

wcfsetup/install/files/lib/system/form/builder/field/wysiwyg/WysiwygFormField.class.php

index 75503ce1cee6414dfc4788ea5f2cd2172c9358a6..040cc89159eb2ac2a2aeb8c10da223d6d540c7aa 100644 (file)
@@ -13,6 +13,7 @@ use wcf\system\form\builder\IFormDocument;
 use wcf\system\form\builder\IObjectTypeFormNode;
 use wcf\system\form\builder\TObjectTypeFormNode;
 use wcf\system\html\input\HtmlInputProcessor;
+use wcf\system\message\censorship\Censorship;
 use wcf\system\message\quote\MessageQuoteManager;
 use wcf\util\StringUtil;
 
@@ -354,6 +355,17 @@ class WysiwygFormField extends AbstractFormField implements IMaximumLengthFormFi
                        $message = $this->htmlInputProcessor->getTextContent();
                        $this->validateMinimumLength($message);
                        $this->validateMaximumLength($message);
+                       
+                       if (empty($this->getValidationErrors()) && ENABLE_CENSORSHIP) {
+                               $result = Censorship::getInstance()->test($message);
+                               if ($result) {
+                                       $this->addValidationError(new FormFieldValidationError(
+                                               'censoredWords',
+                                               'wcf.message.error.censoredWordsFound',
+                                               ['censoredWords' => $result]
+                                       ));
+                               }
+                       }
                }
                
                parent::validate();