Conditionally allow ASCII characters (for Xaekai)

This commit is contained in:
calzoneman 2014-08-29 16:38:57 -05:00
parent 7002874bbb
commit 91c24518c5
4 changed files with 30 additions and 17 deletions

View file

@ -116,8 +116,14 @@ ChatModule.prototype.handleChatMsg = function (user, data) {
return;
}
// Limit to 240 characters, disallow all ASCII control characters except tab (\t)
data.msg = data.msg.substring(0, 240).replace(/[\x00-\x08\x0a-\x1f]+/g, " ");
// Limit to 240 characters
data.msg = data.msg.substring(0, 240);
// If channel doesn't permit them, strip ASCII control characters
if (!this.channel.modules.options ||
!this.channel.modules.options.get("allow_ascii_control")) {
data.msg = data.msg.replace(/[\x00-\x1f]+/g, " ");
}
// Disallow blankposting
if (!data.msg.trim()) {