From: Matthias Schmidt Date: Sat, 17 Aug 2019 12:25:08 +0000 (+0200) Subject: Add censorship enforement for WSYIWYG form builder fields X-Git-Tag: 5.2.0_Beta_1~16^2~7^2~4 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=a1a60aa6e24bbe62334d474be99e20e7b0d481e1;p=GitHub%2FWoltLab%2FWCF.git Add censorship enforement for WSYIWYG form builder fields See #3022 --- 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();