Fixed issue with channelnames with weird characters not working

This commit is contained in:
Kasper Rynning-Tønnesen
2018-03-26 14:48:03 +02:00
parent e5460bf605
commit d15c5c9e89
4 changed files with 28 additions and 28 deletions

View File

@@ -90,8 +90,8 @@ module.exports = function() {
var _list = msg.channel.replace(/ /g,'');
if(_list.length == 0) return;
coll = emojiStrip(_list).toLowerCase();
coll = coll.replace("_", "");
coll = encodeURIComponent(coll).replace(/\W/g, '');
coll = coll.replace(/_/g, "");
coll = filter.clean(coll);
} catch(e) {
return;
@@ -254,8 +254,8 @@ module.exports = function() {
var _list = msg.channel.replace(/ /g,'');
if(_list.length == 0) return;
coll = emojiStrip(_list).toLowerCase();
coll = coll.replace("_", "");
coll = encodeURIComponent(coll).replace(/\W/g, '');
coll = coll.replace(/_/g, "");
//
coll = filter.clean(coll);
} catch(e) {
return;
@@ -275,8 +275,8 @@ module.exports = function() {
coll = obj.channel.toLowerCase().replace(/ /g,'');
if(coll.length == 0) return;
coll = emojiStrip(coll).toLowerCase();
coll = coll.replace("_", "");
coll = encodeURIComponent(coll).replace(/\W/g, '');
coll = coll.replace(/_/g, "");
coll = filter.clean(coll);
} catch(e) {
return;
@@ -296,8 +296,8 @@ module.exports = function() {
coll = arr.list.replace(/ /g,'');
if(coll.length == 0) return;
coll = emojiStrip(coll).toLowerCase();
coll = coll.replace("_", "");
coll = encodeURIComponent(coll).replace(/\W/g, '');
coll = coll.replace(/_/g, "");
coll = filter.clean(coll);
} catch(e) {
return;
@@ -312,8 +312,8 @@ module.exports = function() {
coll = msg.channel.toLowerCase().replace(/ /g,'');
if(coll.length == 0) return;
coll = emojiStrip(coll).toLowerCase();
coll = coll.replace("_", "");
coll = encodeURIComponent(coll).replace(/\W/g, '');
coll = coll.replace(/_/g, "");
coll = filter.clean(coll);
} catch(e) {
return;
@@ -330,8 +330,8 @@ module.exports = function() {
coll = msg.channel.toLowerCase().replace(/ /g,'');
if(coll.length == 0) return;
coll = emojiStrip(coll).toLowerCase();
coll = coll.replace("_", "");
coll = encodeURIComponent(coll).replace(/\W/g, '');
coll = coll.replace(/_/g, "");
coll = filter.clean(coll);
} catch(e) {
return;
@@ -363,8 +363,8 @@ module.exports = function() {
coll = msg.channel.toLowerCase().replace(/ /g,'');
if(coll.length == 0) return;
coll = emojiStrip(coll).toLowerCase();
coll = coll.replace("_", "");
coll = encodeURIComponent(coll).replace(/\W/g, '');
coll = coll.replace(/_/g, "");
coll = filter.clean(coll);
} catch(e) {
return;
@@ -380,8 +380,8 @@ module.exports = function() {
coll = obj.channel.toLowerCase().replace(/ /g,'');
if(coll.length == 0) return;
coll = emojiStrip(coll).toLowerCase();
coll = coll.replace("_", "");
coll = encodeURIComponent(coll).replace(/\W/g, '');
coll = coll.replace(/_/g, "");
coll = filter.clean(coll);
} catch(e) {
return;
@@ -431,8 +431,8 @@ module.exports = function() {
coll = obj.channel.toLowerCase().replace(/ /g,'');
if(coll.length == 0) return;
coll = emojiStrip(coll).toLowerCase();
coll = coll.replace("_", "");
coll = encodeURIComponent(coll).replace(/\W/g, '');
coll = coll.replace(/_/g, "");
coll = filter.clean(coll);
} catch(e) {
return;

View File

@@ -49,8 +49,7 @@ function list(msg, guid, coll, offline, socket) {
coll = msg.channel.toLowerCase().replace(/ /g,'');
var pass = crypto.createHash('sha256').update(Functions.decrypt_string(socketid, msg.pass)).digest("base64");
db.collection('frontpage_lists').find({"_id": coll}, function(err, frontpage_lists){
if(frontpage_lists.length == 1)
{
if(frontpage_lists.length == 1) {
db.collection(coll + "_settings").find(function(err, docs) {
if(docs.length == 0 || (docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || docs[0].userpass == pass))) {
if(docs.length > 0 && docs[0].hasOwnProperty('userpass') && docs[0].userpass != "" && docs[0].userpass == pass) {
@@ -113,8 +112,8 @@ function skip(list, guid, coll, offline, socket) {
coll = list.channel.toLowerCase().replace(/ /g,'');
if(coll.length == 0) return;
coll = emojiStrip(coll).toLowerCase();
coll = coll.replace("_", "");
coll = encodeURIComponent(coll).replace(/\W/g, '');
coll = coll.replace(/_/g, "");
coll = filter.clean(coll);
} catch(e) {
return;

View File

@@ -336,6 +336,7 @@ function add_function(arr, coll, guid, offline, socket) {
if(userpass != "" || arr.userpass == undefined) {
arr.userpass = userpass;
}
db.collection(coll + "_settings").find(function(err, docs){
if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (arr.hasOwnProperty('pass') && docs[0].userpass == crypto.createHash('sha256').update(Functions.decrypt_string(socketid, arr.pass)).digest("base64")))) {
@@ -599,8 +600,8 @@ function shuffle(msg, coll, guid, offline, socket) {
function del(params, socket, socketid) {
if(params.id){
var coll = emojiStrip(params.channel).toLowerCase();
coll = coll.replace("_", "").replace(/ /g,'');
coll = encodeURIComponent(coll).replace(/\W/g, '');
coll = coll.replace(/_/g, "").replace(/ /g,'');
coll = filter.clean(coll);
db.collection(coll + "_settings").find(function(err, docs){
if(docs !== null && docs.length !== 0 && docs[0].adminpass == Functions.hash_pass(Functions.hash_pass(Functions.decrypt_string(socketid, params.adminpass),true)))

View File

@@ -23,8 +23,8 @@ function password(inp, coll, guid, offline, socket) {
coll = inp.channel;
if(coll.length == 0) return;
coll = emojiStrip(coll).toLowerCase();
coll = coll.replace("_", "");
coll = encodeURIComponent(coll).replace(/\W/g, '');
coll = coll.replace(/_/g, "");
coll = filter.clean(coll);
} catch(e) {
return;
@@ -87,8 +87,8 @@ function conf_function(params, coll, guid, offline, socket) {
coll = params.channel.replace(/ /g,'');
if(coll.length == 0) return;
coll = emojiStrip(coll).toLowerCase();
coll = coll.replace("_", "");
coll = encodeURIComponent(coll).replace(/\W/g, '');
coll = coll.replace(/_/g, "");
coll = filter.clean(coll);
} catch(e) {
return;