From 1678565e1157de876f89e6d9fa8acaea6b36e92e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Fri, 22 Oct 2021 11:28:16 +0200 Subject: [PATCH] Stop checking the `enable_censorship` option --- .../files/lib/form/MessageForm.class.php | 21 +++++++------------ .../system/comment/CommentHandler.class.php | 21 ++++++++----------- .../field/wysiwyg/WysiwygFormField.class.php | 8 +++---- .../system/option/AboutMeOptionType.class.php | 11 ++++------ 4 files changed, 25 insertions(+), 36 deletions(-) diff --git a/wcfsetup/install/files/lib/form/MessageForm.class.php b/wcfsetup/install/files/lib/form/MessageForm.class.php index d570c8c00d..45dc408bee 100644 --- a/wcfsetup/install/files/lib/form/MessageForm.class.php +++ b/wcfsetup/install/files/lib/form/MessageForm.class.php @@ -202,13 +202,10 @@ abstract class MessageForm extends AbstractCaptchaForm $this->subject = \mb_substr($this->subject, 0, 255); } - // search for censored words - if (ENABLE_CENSORSHIP) { - $result = Censorship::getInstance()->test($this->subject); - if ($result) { - WCF::getTPL()->assign('censoredWords', $result); - throw new UserInputException('subject', 'censoredWordsFound'); - } + $censoredWords = Censorship::getInstance()->test($this->subject); + if ($censoredWords) { + WCF::getTPL()->assign('censoredWords', $censoredWords); + throw new UserInputException('subject', 'censoredWordsFound'); } } @@ -251,12 +248,10 @@ abstract class MessageForm extends AbstractCaptchaForm } // search for censored words - if (ENABLE_CENSORSHIP) { - $result = Censorship::getInstance()->test($message); - if ($result) { - WCF::getTPL()->assign('censoredWords', $result); - throw new UserInputException('text', 'censoredWordsFound'); - } + $censoredWords = Censorship::getInstance()->test($message); + if ($censoredWords) { + WCF::getTPL()->assign('censoredWords', $censoredWords); + throw new UserInputException('text', 'censoredWordsFound'); } } diff --git a/wcfsetup/install/files/lib/system/comment/CommentHandler.class.php b/wcfsetup/install/files/lib/system/comment/CommentHandler.class.php index 288c63280b..f4a7c3ecfb 100644 --- a/wcfsetup/install/files/lib/system/comment/CommentHandler.class.php +++ b/wcfsetup/install/files/lib/system/comment/CommentHandler.class.php @@ -735,18 +735,15 @@ class CommentHandler extends SingletonFactory */ public static function enforceCensorship($text) { - // search for censored words - if (ENABLE_CENSORSHIP) { - $result = Censorship::getInstance()->test($text); - if ($result) { - throw new UserInputException( - 'text', - WCF::getLanguage()->getDynamicVariable( - 'wcf.message.error.censoredWordsFound', - ['censoredWords' => $result] - ) - ); - } + $censoredWords = Censorship::getInstance()->test($text); + if ($censoredWords) { + throw new UserInputException( + 'text', + WCF::getLanguage()->getDynamicVariable( + 'wcf.message.error.censoredWordsFound', + ['censoredWords' => $censoredWords] + ) + ); } } } 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 5b3fc4ff5a..43ef8b85d1 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 @@ -435,13 +435,13 @@ class WysiwygFormField extends AbstractFormField implements $this->validateMinimumLength($message); $this->validateMaximumLength($message); - if (empty($this->getValidationErrors()) && ENABLE_CENSORSHIP) { - $result = Censorship::getInstance()->test($message); - if ($result) { + if (empty($this->getValidationErrors())) { + $censoredWords = Censorship::getInstance()->test($message); + if ($censoredWords) { $this->addValidationError(new FormFieldValidationError( 'censoredWords', 'wcf.message.error.censoredWordsFound', - ['censoredWords' => $result] + ['censoredWords' => $censoredWords] )); } } diff --git a/wcfsetup/install/files/lib/system/option/AboutMeOptionType.class.php b/wcfsetup/install/files/lib/system/option/AboutMeOptionType.class.php index 6f999c91b7..35dc117167 100644 --- a/wcfsetup/install/files/lib/system/option/AboutMeOptionType.class.php +++ b/wcfsetup/install/files/lib/system/option/AboutMeOptionType.class.php @@ -28,13 +28,10 @@ class AboutMeOptionType extends MessageOptionType throw new UserInputException($option->optionName, 'tooLong'); } - // search for censored words - if (ENABLE_CENSORSHIP) { - $result = Censorship::getInstance()->test($newValue); - if ($result) { - WCF::getTPL()->assign('censoredWords', $result); - throw new UserInputException($option->optionName, 'censoredWordsFound'); - } + $censoredWords = Censorship::getInstance()->test($newValue); + if ($censoredWords) { + WCF::getTPL()->assign('censoredWords', $censoredWords); + throw new UserInputException($option->optionName, 'censoredWordsFound'); } } } -- 2.20.1