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()) {

View File

@ -23,7 +23,8 @@ function OptionsModule(channel) {
enable_link_regex: true, // Use the built-in link filter
password: false, // Channel password (false -> no password required for entry)
allow_dupes: false, // Allow duplicate videos on the playlist
torbanned: false // Block connections from Tor exit nodes
torbanned: false, // Block connections from Tor exit nodes
allow_ascii_control: false // Allow ASCII control characters (\x00-\x1f)
};
}
@ -249,6 +250,10 @@ OptionsModule.prototype.handleSetOptions = function (user, data) {
this.opts.torbanned = Boolean(data.torbanned);
}
if ("allow_ascii_control" in data && user.account.effectiveRank >= 3) {
this.opts.allow_ascii_control = Boolean(data.allow_ascii_control);
}
this.channel.logger.log("[mod] " + user.getName() + " updated channel options");
this.sendOpts(this.channel.users);
};

View File

@ -76,6 +76,7 @@ mixin adminoptions
mixin textbox-auto("cs-externaljs", "External Javascript", "Script URL")
mixin rcheckbox-auto("cs-show_public", "List channel publicly")
mixin rcheckbox-auto("cs-torbanned", "Block connections from Tor")
mixin rcheckbox-auto("cs-allow_ascii_control", "Allow ASCII control characters (e.g. newlines)")
.form-group
.col-sm-8.col-sm-offset-4
span.text-info Changes are automatically saved.

View File

@ -865,6 +865,7 @@ function handleModPermissions() {
$("#cs-voteskip_ratio").val(CHANNEL.opts.voteskip_ratio);
$("#cs-allow_dupes").val(CHANNEL.opts.allow_dupes);
$("#cs-torbanned").val(CHANNEL.opts.torbanned);
$("#cs-allow_ascii_control").val(CHANNEL.opts.allow_ascii_control);
(function() {
if(typeof CHANNEL.opts.maxlength != "number") {
$("#cs-maxlength").val("");