Fixed issue where filter was filtering bad words someplaces, and somewhere it doesnt

This commit is contained in:
Kasper Rynning-Tønnesen
2018-04-19 12:00:44 +02:00
parent dd8aac577a
commit 9a00c426c6
5 changed files with 19 additions and 16 deletions

13
package-lock.json generated
View File

@@ -968,14 +968,6 @@
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
"integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0="
}, },
"emoji-strip": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/emoji-strip/-/emoji-strip-0.0.3.tgz",
"integrity": "sha1-Y+me/gygF0bm3qU1vGSnKkx+0cc=",
"requires": {
"gemoji": "0.1.2"
}
},
"encodeurl": { "encodeurl": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
@@ -1799,11 +1791,6 @@
"globule": "0.1.0" "globule": "0.1.0"
} }
}, },
"gemoji": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/gemoji/-/gemoji-0.1.2.tgz",
"integrity": "sha1-EJIAGfOELmSO9BaMMBUD7ey9FJ4="
},
"get-value": { "get-value": {
"version": "2.0.6", "version": "2.0.6",
"resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz", "resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz",

View File

@@ -67,6 +67,8 @@ function chat(msg, guid, offline, socket) {
return; return;
} }
var coll = msg.channel.toLowerCase().replace(/ /g,''); var coll = msg.channel.toLowerCase().replace(/ /g,'');
coll = emojiStrip(coll).toLowerCase();
coll = filter.clean(coll);
Functions.getSessionAdminUser(Functions.getSession(socket), coll, function(userpass) { Functions.getSessionAdminUser(Functions.getSession(socket), coll, function(userpass) {
if(userpass != "" || msg.pass == undefined) { if(userpass != "" || msg.pass == undefined) {
msg.pass = userpass; msg.pass = userpass;
@@ -118,7 +120,8 @@ function all_chat(msg, guid, offline, socket) {
} }
var coll = msg.channel.toLowerCase().replace(/ /g,''); var coll = msg.channel.toLowerCase().replace(/ /g,'');
var data = msg.data; var data = msg.data;
coll = emojiStrip(coll).toLowerCase();
coll = filter.clean(coll);
Functions.check_inlist(coll, guid, socket, offline); Functions.check_inlist(coll, guid, socket, offline);
if(data !== "" && data !== undefined && data !== null && if(data !== "" && data !== undefined && data !== null &&
data.length < 151 && data.replace(/\s/g, '').length){ data.length < 151 && data.replace(/\s/g, '').length){

View File

@@ -64,6 +64,8 @@ module.exports = function() {
socketid = msg.socket_id; socketid = msg.socket_id;
socket.zoff_id = socketid; socket.zoff_id = socketid;
coll = msg.channel.toLowerCase().replace(/ /g,''); coll = msg.channel.toLowerCase().replace(/ /g,'');
coll = emojiStrip(coll).toLowerCase();
coll = filter.clean(coll);
in_list = true; in_list = true;
chromecast_object = true; chromecast_object = true;
socket.join(coll); socket.join(coll);
@@ -156,6 +158,8 @@ module.exports = function() {
offline = true; offline = true;
if(channel != "") coll = channel; if(channel != "") coll = channel;
if(coll !== undefined) { if(coll !== undefined) {
coll = emojiStrip(coll).toLowerCase();
coll = filter.clean(coll);
db.collection("connected_users").findAndModify({ db.collection("connected_users").findAndModify({
query: {"_id": coll}, query: {"_id": coll},
@@ -254,7 +258,6 @@ module.exports = function() {
} catch(e) { } catch(e) {
return; return;
} }
if(msg.hasOwnProperty("offline") && msg.offline) { if(msg.hasOwnProperty("offline") && msg.offline) {
offline = true; offline = true;
} }
@@ -396,6 +399,8 @@ module.exports = function() {
socket.on("left_channel", function(msg) { socket.on("left_channel", function(msg) {
if(msg.hasOwnProperty("channel") && msg.channel != "" && typeof(msg.channel) == "string") { if(msg.hasOwnProperty("channel") && msg.channel != "" && typeof(msg.channel) == "string") {
coll = msg.channel.replace(/ /g,''); coll = msg.channel.replace(/ /g,'');
coll = emojiStrip(coll).toLowerCase();
coll = filter.clean(coll);
List.left_channel(coll, guid, short_id, in_list, socket, false); List.left_channel(coll, guid, short_id, in_list, socket, false);
} }
}) })

View File

@@ -47,6 +47,8 @@ function list(msg, guid, coll, offline, socket) {
return; return;
} }
coll = msg.channel.toLowerCase().replace(/ /g,''); coll = msg.channel.toLowerCase().replace(/ /g,'');
coll = emojiStrip(coll).toLowerCase();
coll = filter.clean(coll);
var pass = crypto.createHash('sha256').update(Functions.decrypt_string(msg.pass)).digest("base64"); var pass = crypto.createHash('sha256').update(Functions.decrypt_string(msg.pass)).digest("base64");
db.collection('frontpage_lists').find({"_id": coll}, function(err, frontpage_lists){ db.collection('frontpage_lists').find({"_id": coll}, function(err, frontpage_lists){
if(frontpage_lists.length == 1) { if(frontpage_lists.length == 1) {
@@ -119,6 +121,7 @@ function skip(list, guid, coll, offline, socket) {
return; return;
} }
} }
if(!list.hasOwnProperty("id") || !list.hasOwnProperty("channel") || if(!list.hasOwnProperty("id") || !list.hasOwnProperty("channel") ||
typeof(list.id) != "string" || typeof(list.channel) != "string") { typeof(list.id) != "string" || typeof(list.channel) != "string") {
var result = { var result = {

View File

@@ -469,6 +469,8 @@ function voteUndecided(msg, coll, guid, offline, socket) {
return; return;
} }
coll = msg.channel.toLowerCase().replace(/ /g,''); coll = msg.channel.toLowerCase().replace(/ /g,'');
coll = emojiStrip(coll).toLowerCase();
coll = filter.clean(coll);
Functions.getSessionAdminUser(Functions.getSession(socket), coll, function(userpass, adminpass) { Functions.getSessionAdminUser(Functions.getSession(socket), coll, function(userpass, adminpass) {
if(adminpass != "" || msg.adminpass == undefined) { if(adminpass != "" || msg.adminpass == undefined) {
msg.adminpass = adminpass; msg.adminpass = adminpass;
@@ -533,7 +535,8 @@ function shuffle(msg, coll, guid, offline, socket) {
return; return;
} }
coll = msg.channel.toLowerCase().replace(/ /g,''); coll = msg.channel.toLowerCase().replace(/ /g,'');
coll = emojiStrip(coll).toLowerCase();
coll = filter.clean(coll);
Functions.getSessionAdminUser(Functions.getSession(socket), coll, function(userpass, adminpass) { Functions.getSessionAdminUser(Functions.getSession(socket), coll, function(userpass, adminpass) {
if(adminpass != "" || msg.adminpass == undefined) { if(adminpass != "" || msg.adminpass == undefined) {
msg.adminpass = adminpass; msg.adminpass = adminpass;
@@ -654,6 +657,8 @@ function delete_all(msg, coll, guid, offline, socket) {
coll = msg.channel; coll = msg.channel;
} }
coll = coll.replace(/ /g,''); coll = coll.replace(/ /g,'');
coll = emojiStrip(coll).toLowerCase();
coll = filter.clean(coll);
Functions.getSessionAdminUser(Functions.getSession(socket), coll, function(userpass, adminpass, gotten) { Functions.getSessionAdminUser(Functions.getSession(socket), coll, function(userpass, adminpass, gotten) {
if(adminpass != "" || msg.adminpass == undefined) { if(adminpass != "" || msg.adminpass == undefined) {
msg.adminpass = adminpass; msg.adminpass = adminpass;