1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2024-10-31 14:10:08 +00:00

Check for allowed BBCodes

Closes #18
This commit is contained in:
Tim Düsterhus 2013-03-11 15:28:51 +01:00
parent daeb63d219
commit 850ccd65fd
3 changed files with 11 additions and 6 deletions

View File

@ -52,6 +52,12 @@ public function validateSend() {
// validate text // validate text
if (strlen($this->parameters['text']) > CHAT_MAX_LENGTH) throw new UserInputException('text', 'tooLong'); if (strlen($this->parameters['text']) > CHAT_MAX_LENGTH) throw new UserInputException('text', 'tooLong');
// search for disallowed bbcodes
$disallowedBBCodes = \wcf\system\bbcode\BBCodeParser::getInstance()->validateBBCodes($this->parameters['text'], explode(',', WCF::getSession()->getPermission('user.chat.allowedBBCodes')));
if (!empty($disallowedBBCodes)) {
throw new UserInputException('text', WCF::getLanguage()->getDynamicVariable('wcf.message.error.disallowedBBCodes', array('disallowedBBCodes' => $disallowedBBCodes)));
}
// search for censored words // search for censored words
if (ENABLE_CENSORSHIP) { if (ENABLE_CENSORSHIP) {
$result = \wcf\system\message\censorship\Censorship::getInstance()->test($this->parameters['text']); $result = \wcf\system\message\censorship\Censorship::getInstance()->test($this->parameters['text']);

View File

@ -37,12 +37,6 @@
<defaultvalue>1</defaultvalue> <defaultvalue>1</defaultvalue>
<showorder>5</showorder> <showorder>5</showorder>
</option> </option>
<option name="chat_enable_bbcodes">
<categoryname>chat.general</categoryname>
<optiontype>boolean</optiontype>
<defaultvalue>1</defaultvalue>
<showorder>6</showorder>
</option>
<option name="chat_max_length"> <option name="chat_max_length">
<categoryname>chat.general</categoryname> <categoryname>chat.general</categoryname>
<optiontype>integer</optiontype> <optiontype>integer</optiontype>

View File

@ -32,6 +32,11 @@
<defaultvalue>0</defaultvalue> <defaultvalue>0</defaultvalue>
<admindefaultvalue>0</admindefaultvalue> <admindefaultvalue>0</admindefaultvalue>
</option> </option>
<option name="user.chat.allowedBBCodes">
<categoryname>user.chat</categoryname>
<optiontype>BBCodeSelect</optiontype>
<defaultvalue>none</defaultvalue>
</option>
<option name="mod.chat.canAlwaysEnter"> <option name="mod.chat.canAlwaysEnter">
<categoryname>mod.chat</categoryname> <categoryname>mod.chat</categoryname>
<optiontype>boolean</optiontype> <optiontype>boolean</optiontype>