processor = new HtmlInputProcessor(); $this->setDisallowedBBCodes(); } private function setDisallowedBBCodes() { BBCodeHandler::getInstance()->setDisallowedBBCodes(\explode( ',', WCF::getSession()->getPermission('user.chat.disallowedBBCodes') )); } public function setText($text) { if ($this->text === $text) { return; } $this->text = $text; $this->setDisallowedBBCodes(); $this->processor->process( $text, 'be.bastelstu.chat.message', 0 ); } public function validateText() { if ($this->processor->appearsToBeEmpty()) { throw new UserInputException( 'message', WCF::getLanguage()->getDynamicVariable('wcf.global.form.error.empty') ); } $message = $this->processor->getTextContent(); // validate message length if (\mb_strlen($message) > CHAT_MAX_LENGTH) { throw new UserInputException( 'message', WCF::getLanguage()->getDynamicVariable( 'wcf.message.error.tooLong', [ 'maxTextLength' => CHAT_MAX_LENGTH, ] ) ); } // search for disallowed bbcodes $this->setDisallowedBBCodes(); $disallowedBBCodes = $this->processor->validate(); if (!empty($disallowedBBCodes)) { throw new UserInputException( 'message', WCF::getLanguage()->getDynamicVariable( 'wcf.message.error.disallowedBBCodes', [ 'disallowedBBCodes' => $disallowedBBCodes, ] ) ); } // search for censored words if (ENABLE_CENSORSHIP) { $result = Censorship::getInstance()->test($message); if ($result) { throw new UserInputException( 'message', WCF::getLanguage()->getDynamicVariable( 'wcf.message.error.censoredWordsFound', [ 'censoredWords' => $result, ] ) ); } } } }