From a1a60aa6e24bbe62334d474be99e20e7b0d481e1 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Sat, 17 Aug 2019 14:25:08 +0200 Subject: [PATCH] Add censorship enforement for WSYIWYG form builder fields See #3022 --- .../builder/field/wysiwyg/WysiwygFormField.class.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/wcfsetup/install/files/lib/system/form/builder/field/wysiwyg/WysiwygFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/wysiwyg/WysiwygFormField.class.php index 75503ce1ce..040cc89159 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/wysiwyg/WysiwygFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/wysiwyg/WysiwygFormField.class.php @@ -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(); -- 2.20.1