mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 03:55:55 +01:00
ESlint no-useless-escape, no-else-return
This commit is contained in:
@@ -71,8 +71,8 @@
|
|||||||
"new-cap": "off",
|
"new-cap": "off",
|
||||||
"no-lonely-if": "off",
|
"no-lonely-if": "off",
|
||||||
"radix": "off",
|
"radix": "off",
|
||||||
"no-else-return": "off",
|
// "no-else-return": "off",
|
||||||
"no-useless-escape": "off",
|
// "no-useless-escape": "off",
|
||||||
// "block-scoped-var": "off",
|
// "block-scoped-var": "off",
|
||||||
// "operator-assignment": "off",
|
// "operator-assignment": "off",
|
||||||
// "yoda": "off",
|
// "yoda": "off",
|
||||||
|
|||||||
@@ -165,9 +165,8 @@ define('admin/manage/flags', [
|
|||||||
}, function (err) {
|
}, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return app.alertError(err.message);
|
||||||
} else {
|
|
||||||
app.alertSuccess('[[topic:flag_manage_saved]]');
|
|
||||||
}
|
}
|
||||||
|
app.alertSuccess('[[topic:flag_manage_saved]]');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -377,9 +377,8 @@ $(document).ready(function () {
|
|||||||
if ($(this).attr('data-ajaxify') === 'false') {
|
if ($(this).attr('data-ajaxify') === 'false') {
|
||||||
if (!internalLink) {
|
if (!internalLink) {
|
||||||
return;
|
return;
|
||||||
} else {
|
|
||||||
return e.preventDefault();
|
|
||||||
}
|
}
|
||||||
|
return e.preventDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default behaviour for rss feeds
|
// Default behaviour for rss feeds
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ define('forum/account/edit', ['forum/account/header', 'translator', 'components'
|
|||||||
if ($('#confirm-username').val() !== app.user.username) {
|
if ($('#confirm-username').val() !== app.user.username) {
|
||||||
app.alertError('[[error:invalid-username]]');
|
app.alertError('[[error:invalid-username]]');
|
||||||
return false;
|
return false;
|
||||||
} else {
|
}
|
||||||
socket.emit('user.deleteAccount', {}, function (err) {
|
socket.emit('user.deleteAccount', {}, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return app.alertError(err.message);
|
||||||
@@ -174,7 +174,6 @@ define('forum/account/edit', ['forum/account/header', 'translator', 'components'
|
|||||||
|
|
||||||
window.location.href = config.relative_path + '/';
|
window.location.href = config.relative_path + '/';
|
||||||
});
|
});
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
modal.on('shown.bs.modal', function () {
|
modal.on('shown.bs.modal', function () {
|
||||||
|
|||||||
@@ -45,9 +45,8 @@ $('document').ready(function () {
|
|||||||
$('html, body').animate({ scrollTop: '0px' }, 400);
|
$('html, body').animate({ scrollTop: '0px' }, 400);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
} else {
|
|
||||||
$('#submit .fa-spin').removeClass('hide');
|
|
||||||
}
|
}
|
||||||
|
$('#submit .fa-spin').removeClass('hide');
|
||||||
}
|
}
|
||||||
|
|
||||||
function activate(type, el) {
|
function activate(type, el) {
|
||||||
|
|||||||
@@ -7,9 +7,8 @@ define('components', function () {
|
|||||||
'topic/teaser': function (tid) {
|
'topic/teaser': function (tid) {
|
||||||
if (tid) {
|
if (tid) {
|
||||||
return $('[component="category/topic"][data-tid="' + tid + '"] [component="topic/teaser"]');
|
return $('[component="category/topic"][data-tid="' + tid + '"] [component="topic/teaser"]');
|
||||||
} else {
|
|
||||||
return $('[component="topic/teaser"]');
|
|
||||||
}
|
}
|
||||||
|
return $('[component="topic/teaser"]');
|
||||||
},
|
},
|
||||||
topic: function (name, value) {
|
topic: function (name, value) {
|
||||||
return $('[component="topic"][data-' + name + '="' + value + '"]');
|
return $('[component="topic"][data-' + name + '="' + value + '"]');
|
||||||
@@ -61,9 +60,8 @@ define('components', function () {
|
|||||||
|
|
||||||
if (components.core[arguments[0]] && args.length) {
|
if (components.core[arguments[0]] && args.length) {
|
||||||
return components.core[arguments[0]].apply(this, args);
|
return components.core[arguments[0]].apply(this, args);
|
||||||
} else {
|
|
||||||
return $('[component="' + arguments[0] + '"]');
|
|
||||||
}
|
}
|
||||||
|
return $('[component="' + arguments[0] + '"]');
|
||||||
};
|
};
|
||||||
|
|
||||||
return components;
|
return components;
|
||||||
|
|||||||
@@ -56,18 +56,16 @@
|
|||||||
helpers.escape = function (str) {
|
helpers.escape = function (str) {
|
||||||
if (typeof utils !== 'undefined') {
|
if (typeof utils !== 'undefined') {
|
||||||
return utils.escapeHTML(str);
|
return utils.escapeHTML(str);
|
||||||
} else {
|
|
||||||
return require('../utils').escapeHTML(str);
|
|
||||||
}
|
}
|
||||||
|
return require('../utils').escapeHTML(str);
|
||||||
};
|
};
|
||||||
|
|
||||||
helpers.stripTags = function (str) {
|
helpers.stripTags = function (str) {
|
||||||
if (typeof window !== 'undefined' && window.S) {
|
if (typeof window !== 'undefined' && window.S) {
|
||||||
return window.S(String(str)).stripTags().s;
|
return window.S(String(str)).stripTags().s;
|
||||||
} else {
|
}
|
||||||
var S = require('string');
|
var S = require('string');
|
||||||
return S(String(str)).stripTags().s;
|
return S(String(str)).stripTags().s;
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
helpers.generateCategoryBackground = function (category) {
|
helpers.generateCategoryBackground = function (category) {
|
||||||
@@ -157,9 +155,8 @@
|
|||||||
return '<button class="btn btn-link" data-action="rejectInvite" data-group="' + groupObj.displayName + '">[[groups:membership.reject]]</button><button class="btn btn-success" data-action="acceptInvite" data-group="' + groupObj.name + '"><i class="fa fa-plus"></i> [[groups:membership.accept-invitation]]</button>';
|
return '<button class="btn btn-link" data-action="rejectInvite" data-group="' + groupObj.displayName + '">[[groups:membership.reject]]</button><button class="btn btn-success" data-action="acceptInvite" data-group="' + groupObj.name + '"><i class="fa fa-plus"></i> [[groups:membership.accept-invitation]]</button>';
|
||||||
} else if (!groupObj.disableJoinRequests && groupObj.name !== 'administrators') {
|
} else if (!groupObj.disableJoinRequests && groupObj.name !== 'administrators') {
|
||||||
return '<button class="btn btn-success" data-action="join" data-group="' + groupObj.displayName + '"><i class="fa fa-plus"></i> [[groups:membership.join-group]]</button>';
|
return '<button class="btn btn-success" data-action="join" data-group="' + groupObj.displayName + '"><i class="fa fa-plus"></i> [[groups:membership.join-group]]</button>';
|
||||||
} else {
|
|
||||||
return '';
|
|
||||||
}
|
}
|
||||||
|
return '';
|
||||||
};
|
};
|
||||||
|
|
||||||
helpers.spawnPrivilegeStates = function (member, privileges) {
|
helpers.spawnPrivilegeStates = function (member, privileges) {
|
||||||
@@ -184,25 +181,21 @@
|
|||||||
helpers.renderTopicImage = function (topicObj) {
|
helpers.renderTopicImage = function (topicObj) {
|
||||||
if (topicObj.thumb) {
|
if (topicObj.thumb) {
|
||||||
return '<img src="' + topicObj.thumb + '" class="img-circle user-img" title="' + topicObj.user.username + '" />';
|
return '<img src="' + topicObj.thumb + '" class="img-circle user-img" title="' + topicObj.user.username + '" />';
|
||||||
} else {
|
|
||||||
return '<img component="user/picture" data-uid="' + topicObj.user.uid + '" src="' + topicObj.user.picture + '" class="user-img" title="' + topicObj.user.username + '" />';
|
|
||||||
}
|
}
|
||||||
|
return '<img component="user/picture" data-uid="' + topicObj.user.uid + '" src="' + topicObj.user.picture + '" class="user-img" title="' + topicObj.user.username + '" />';
|
||||||
};
|
};
|
||||||
|
|
||||||
helpers.renderDigestAvatar = function (block) {
|
helpers.renderDigestAvatar = function (block) {
|
||||||
if (block.teaser) {
|
if (block.teaser) {
|
||||||
if (block.teaser.user.picture) {
|
if (block.teaser.user.picture) {
|
||||||
return '<img style="vertical-align: middle; width: 16px; height: 16px; padding-right: 1em;" src="' + block.teaser.user.picture + '" title="' + block.teaser.user.username + '" />';
|
return '<img style="vertical-align: middle; width: 16px; height: 16px; padding-right: 1em;" src="' + block.teaser.user.picture + '" title="' + block.teaser.user.username + '" />';
|
||||||
} else {
|
}
|
||||||
return '<div style="width: 16px; height: 16px; line-height: 16px; font-size: 10px; margin-right: 1em; background-color: ' + block.teaser.user['icon:bgColor'] + '; color: white; text-align: center; display: inline-block;">' + block.teaser.user['icon:text'] + '</div>';
|
return '<div style="width: 16px; height: 16px; line-height: 16px; font-size: 10px; margin-right: 1em; background-color: ' + block.teaser.user['icon:bgColor'] + '; color: white; text-align: center; display: inline-block;">' + block.teaser.user['icon:text'] + '</div>';
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if (block.user.picture) {
|
if (block.user.picture) {
|
||||||
return '<img style="vertical-align: middle; width: 16px; height: 16px; padding-right: 1em;" src="' + block.user.picture + '" title="' + block.user.username + '" />';
|
return '<img style="vertical-align: middle; width: 16px; height: 16px; padding-right: 1em;" src="' + block.user.picture + '" title="' + block.user.username + '" />';
|
||||||
} else {
|
}
|
||||||
return '<div style="width: 16px; height: 16px; line-height: 16px; font-size: 10px; margin-right: 1em; background-color: ' + block.user['icon:bgColor'] + '; color: white; text-align: center; display: inline-block;">' + block.user['icon:text'] + '</div>';
|
return '<div style="width: 16px; height: 16px; line-height: 16px; font-size: 10px; margin-right: 1em; background-color: ' + block.user['icon:bgColor'] + '; color: white; text-align: center; display: inline-block;">' + block.user['icon:text'] + '</div>';
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
helpers.userAgentIcons = function (data) {
|
helpers.userAgentIcons = function (data) {
|
||||||
|
|||||||
@@ -36,9 +36,8 @@ define('settings', function () {
|
|||||||
hook = plugin[name];
|
hook = plugin[name];
|
||||||
if (typeof hook === 'function') {
|
if (typeof hook === 'function') {
|
||||||
return hook;
|
return hook;
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
helper = {
|
helper = {
|
||||||
@@ -48,9 +47,8 @@ define('settings', function () {
|
|||||||
deepClone: function (obj) {
|
deepClone: function (obj) {
|
||||||
if (typeof obj === 'object') {
|
if (typeof obj === 'object') {
|
||||||
return JSON.parse(JSON.stringify(obj));
|
return JSON.parse(JSON.stringify(obj));
|
||||||
} else {
|
|
||||||
return obj;
|
|
||||||
}
|
}
|
||||||
|
return obj;
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
Creates a new Element with given data.
|
Creates a new Element with given data.
|
||||||
@@ -169,7 +167,7 @@ define('settings', function () {
|
|||||||
value = element.val();
|
value = element.val();
|
||||||
var array = (value != null && value.split(split || ',')) || [];
|
var array = (value != null && value.split(split || ',')) || [];
|
||||||
return helper.cleanArray(array, trim, empty);
|
return helper.cleanArray(array, trim, empty);
|
||||||
} else {
|
}
|
||||||
value = element.val();
|
value = element.val();
|
||||||
if (trim && value != null && typeof value.trim === 'function') {
|
if (trim && value != null && typeof value.trim === 'function') {
|
||||||
value = value.trim();
|
value = value.trim();
|
||||||
@@ -177,7 +175,6 @@ define('settings', function () {
|
|||||||
if (empty || (value !== undefined && (value == null || value.length !== 0))) {
|
if (empty || (value !== undefined && (value == null || value.length !== 0))) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
Calls the set-hook of the given element.
|
Calls the set-hook of the given element.
|
||||||
|
|||||||
@@ -78,9 +78,8 @@ define('settings/key', function () {
|
|||||||
return String.fromCharCode(code).toUpperCase();
|
return String.fromCharCode(code).toUpperCase();
|
||||||
} else if (code >= 112 && code <= 123) {
|
} else if (code >= 112 && code <= 123) {
|
||||||
return 'F' + (code - 111);
|
return 'F' + (code - 111);
|
||||||
} else {
|
|
||||||
return keyMap[code] || ('#' + code);
|
|
||||||
}
|
}
|
||||||
|
return keyMap[code] || ('#' + code);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -99,9 +98,8 @@ define('settings/key', function () {
|
|||||||
if (!key.char) {
|
if (!key.char) {
|
||||||
if (human) {
|
if (human) {
|
||||||
return 'Enter a key';
|
return 'Enter a key';
|
||||||
} else {
|
|
||||||
return '';
|
|
||||||
}
|
}
|
||||||
|
return '';
|
||||||
}
|
}
|
||||||
if (!separator || /CtrlAShifMea#/.test(separator)) {
|
if (!separator || /CtrlAShifMea#/.test(separator)) {
|
||||||
separator = human ? ' + ' : '+';
|
separator = human ? ' + ' : '+';
|
||||||
|
|||||||
@@ -111,7 +111,7 @@
|
|||||||
tag = tag.trim().toLowerCase();
|
tag = tag.trim().toLowerCase();
|
||||||
// see https://github.com/NodeBB/NodeBB/issues/4378
|
// see https://github.com/NodeBB/NodeBB/issues/4378
|
||||||
tag = tag.replace(/\u202E/gi, '');
|
tag = tag.replace(/\u202E/gi, '');
|
||||||
tag = tag.replace(/[,\/#!$%\^\*;:{}=_`<>'"~()?\|]/g, '');
|
tag = tag.replace(/[,/#!$%^*;:{}=_`<>'"~()?|]/g, '');
|
||||||
tag = tag.substr(0, maxLength || 15).trim();
|
tag = tag.substr(0, maxLength || 15).trim();
|
||||||
var matches = tag.match(/^[.-]*(.+?)[.-]*$/);
|
var matches = tag.match(/^[.-]*(.+?)[.-]*$/);
|
||||||
if (matches && matches.length > 1) {
|
if (matches && matches.length > 1) {
|
||||||
@@ -121,7 +121,7 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
removePunctuation: function (str) {
|
removePunctuation: function (str) {
|
||||||
return str.replace(/[\.,-\/#!$%\^&\*;:{}=\-_`<>'"~()?]/g, '');
|
return str.replace(/[.,-/#!$%^&*;:{}=\-_`<>'"~()?]/g, '');
|
||||||
},
|
},
|
||||||
|
|
||||||
isEmailValid: function (email) {
|
isEmailValid: function (email) {
|
||||||
@@ -129,7 +129,7 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
isUserNameValid: function (name) {
|
isUserNameValid: function (name) {
|
||||||
return (name && name !== '' && (/^['"\s\-\+.*0-9\u00BF-\u1FFF\u2C00-\uD7FF\w]+$/.test(name)));
|
return (name && name !== '' && (/^['"\s\-+.*0-9\u00BF-\u1FFF\u2C00-\uD7FF\w]+$/.test(name)));
|
||||||
},
|
},
|
||||||
|
|
||||||
isPasswordValid: function (password) {
|
isPasswordValid: function (password) {
|
||||||
@@ -390,7 +390,7 @@
|
|||||||
var type = typeof str;
|
var type = typeof str;
|
||||||
if (type !== 'string') {
|
if (type !== 'string') {
|
||||||
return str;
|
return str;
|
||||||
} else {
|
}
|
||||||
var nb = parseFloat(str);
|
var nb = parseFloat(str);
|
||||||
if (!isNaN(nb) && isFinite(str)) {
|
if (!isNaN(nb) && isFinite(str)) {
|
||||||
return nb;
|
return nb;
|
||||||
@@ -407,7 +407,6 @@
|
|||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// Safely get/set chained properties on an object
|
// Safely get/set chained properties on an object
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ function filterDirectories(directories) {
|
|||||||
// exclude category.tpl, group.tpl, category-analytics.tpl
|
// exclude category.tpl, group.tpl, category-analytics.tpl
|
||||||
return !dir.includes('/partials/') &&
|
return !dir.includes('/partials/') &&
|
||||||
/\/.*\//.test(dir) &&
|
/\/.*\//.test(dir) &&
|
||||||
!/manage\/(category|group|category\-analytics)$/.test(dir);
|
!/manage\/(category|group|category-analytics)$/.test(dir);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ function sanitize(html) {
|
|||||||
function simplify(translations) {
|
function simplify(translations) {
|
||||||
return translations
|
return translations
|
||||||
// remove all mustaches
|
// remove all mustaches
|
||||||
.replace(/(?:\{{1,2}[^\}]*?\}{1,2})/g, '')
|
.replace(/(?:\{{1,2}[^}]*?\}{1,2})/g, '')
|
||||||
// collapse whitespace
|
// collapse whitespace
|
||||||
.replace(/(?:[ \t]*[\n\r]+[ \t]*)+/g, '\n')
|
.replace(/(?:[ \t]*[\n\r]+[ \t]*)+/g, '\n')
|
||||||
.replace(/[\t ]+/g, ' ');
|
.replace(/[\t ]+/g, ' ');
|
||||||
|
|||||||
@@ -46,9 +46,8 @@ sessionController.revoke = function (req, res, next) {
|
|||||||
], function (err) {
|
], function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return res.status(500).send(err.message);
|
return res.status(500).send(err.message);
|
||||||
} else {
|
|
||||||
return res.sendStatus(200);
|
|
||||||
}
|
}
|
||||||
|
return res.sendStatus(200);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -113,11 +113,10 @@ function registerAndLoginUser(req, res, userData, callback) {
|
|||||||
|
|
||||||
if (!deferRegistration) {
|
if (!deferRegistration) {
|
||||||
return next();
|
return next();
|
||||||
} else {
|
}
|
||||||
userData.register = true;
|
userData.register = true;
|
||||||
req.session.registration = userData;
|
req.session.registration = userData;
|
||||||
return res.json({ referrer: nconf.get('relative_path') + '/register/complete' });
|
return res.json({ referrer: nconf.get('relative_path') + '/register/complete' });
|
||||||
}
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
function (next) {
|
function (next) {
|
||||||
|
|||||||
@@ -131,9 +131,8 @@ Controllers.login = function (req, res, next) {
|
|||||||
return helpers.redirect(res, {
|
return helpers.redirect(res, {
|
||||||
external: data.authentication[0].url,
|
external: data.authentication[0].url,
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
return res.redirect(nconf.get('relative_path') + data.authentication[0].url);
|
|
||||||
}
|
}
|
||||||
|
return res.redirect(nconf.get('relative_path') + data.authentication[0].url);
|
||||||
}
|
}
|
||||||
if (req.uid) {
|
if (req.uid) {
|
||||||
user.getUserFields(req.uid, ['username', 'email'], function (err, user) {
|
user.getUserFields(req.uid, ['username', 'email'], function (err, user) {
|
||||||
|
|||||||
@@ -207,10 +207,10 @@ module.exports = function (redisClient, module) {
|
|||||||
maxmax = '+';
|
maxmax = '+';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (min !== minmin && !min.match(/^[\[\(]/)) {
|
if (min !== minmin && !min.match(/^[[(]/)) {
|
||||||
min = '[' + min;
|
min = '[' + min;
|
||||||
}
|
}
|
||||||
if (max !== maxmax && !max.match(/^[\[\(]/)) {
|
if (max !== maxmax && !max.match(/^[[(]/)) {
|
||||||
max = '[' + max;
|
max = '[' + max;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -121,9 +121,8 @@ module.exports = function (Groups) {
|
|||||||
return -1;
|
return -1;
|
||||||
} else if (!a.isOwner && b.isOwner) {
|
} else if (!a.isOwner && b.isOwner) {
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
});
|
});
|
||||||
next(null, results);
|
next(null, results);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -132,9 +132,8 @@ var opts = {
|
|||||||
*/
|
*/
|
||||||
if (meta.config.loggerStatus > 0) {
|
if (meta.config.loggerStatus > 0) {
|
||||||
return opts.express.ofn(req, res, next);
|
return opts.express.ofn(req, res, next);
|
||||||
} else {
|
|
||||||
return next();
|
|
||||||
}
|
}
|
||||||
|
return next();
|
||||||
};
|
};
|
||||||
|
|
||||||
Logger.prepare_io_string = function (_type, _uid, _args) {
|
Logger.prepare_io_string = function (_type, _uid, _args) {
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ function getTranslationTree(callback) {
|
|||||||
// pull languages and namespaces from paths
|
// pull languages and namespaces from paths
|
||||||
function extrude(languageDir, paths) {
|
function extrude(languageDir, paths) {
|
||||||
paths.forEach(function (p) {
|
paths.forEach(function (p) {
|
||||||
var rel = p.split(languageDir)[1].split(/[\/\\]/).slice(1);
|
var rel = p.split(languageDir)[1].split(/[/\\]/).slice(1);
|
||||||
var language = rel.shift().replace('_', '-').replace('@', '-x-');
|
var language = rel.shift().replace('_', '-').replace('@', '-x-');
|
||||||
var namespace = rel.join('/').replace(/\.json$/, '');
|
var namespace = rel.join('/').replace(/\.json$/, '');
|
||||||
|
|
||||||
|
|||||||
@@ -64,9 +64,8 @@ middleware.ensureSelfOrGlobalPrivilege = function (req, res, next) {
|
|||||||
return next(err);
|
return next(err);
|
||||||
} else if (ok) {
|
} else if (ok) {
|
||||||
return next();
|
return next();
|
||||||
} else {
|
|
||||||
controllers.helpers.notAllowed(req, res);
|
|
||||||
}
|
}
|
||||||
|
controllers.helpers.notAllowed(req, res);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
controllers.helpers.notAllowed(req, res);
|
controllers.helpers.notAllowed(req, res);
|
||||||
@@ -121,11 +120,10 @@ middleware.prepareAPI = function (req, res, next) {
|
|||||||
middleware.routeTouchIcon = function (req, res) {
|
middleware.routeTouchIcon = function (req, res) {
|
||||||
if (meta.config['brand:touchIcon'] && validator.isURL(meta.config['brand:touchIcon'])) {
|
if (meta.config['brand:touchIcon'] && validator.isURL(meta.config['brand:touchIcon'])) {
|
||||||
return res.redirect(meta.config['brand:touchIcon']);
|
return res.redirect(meta.config['brand:touchIcon']);
|
||||||
} else {
|
}
|
||||||
return res.sendFile(path.join(__dirname, '../../public', meta.config['brand:touchIcon'] || '/logo.png'), {
|
return res.sendFile(path.join(__dirname, '../../public', meta.config['brand:touchIcon'] || '/logo.png'), {
|
||||||
maxAge: req.app.enabled('cache') ? 5184000000 : 0,
|
maxAge: req.app.enabled('cache') ? 5184000000 : 0,
|
||||||
});
|
});
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
middleware.privateTagListing = function (req, res, next) {
|
middleware.privateTagListing = function (req, res, next) {
|
||||||
|
|||||||
@@ -148,12 +148,11 @@ module.exports = function (middleware) {
|
|||||||
// If the user's session contains registration data, redirect the user to complete registration
|
// If the user's session contains registration data, redirect the user to complete registration
|
||||||
if (!req.session.hasOwnProperty('registration')) {
|
if (!req.session.hasOwnProperty('registration')) {
|
||||||
return next();
|
return next();
|
||||||
} else {
|
}
|
||||||
if (!req.path.endsWith('/register/complete')) {
|
if (!req.path.endsWith('/register/complete')) {
|
||||||
controllers.helpers.redirect(res, '/register/complete');
|
controllers.helpers.redirect(res, '/register/complete');
|
||||||
} else {
|
} else {
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -316,9 +316,8 @@ var middleware;
|
|||||||
return 1;
|
return 1;
|
||||||
} else if (a.name < b.name) {
|
} else if (a.name < b.name) {
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
callback(null, pluginArray);
|
callback(null, pluginArray);
|
||||||
|
|||||||
@@ -57,10 +57,9 @@ module.exports = function (Plugins) {
|
|||||||
method = data.method.split('.').reduce(function (memo, prop) {
|
method = data.method.split('.').reduce(function (memo, prop) {
|
||||||
if (memo && memo[prop]) {
|
if (memo && memo[prop]) {
|
||||||
return memo[prop];
|
return memo[prop];
|
||||||
} else {
|
}
|
||||||
// Couldn't find method by path, aborting
|
// Couldn't find method by path, aborting
|
||||||
return null;
|
return null;
|
||||||
}
|
|
||||||
}, Plugins.libraries[data.id]);
|
}, Plugins.libraries[data.id]);
|
||||||
|
|
||||||
// Write the actual method reference to the hookObj
|
// Write the actual method reference to the hookObj
|
||||||
|
|||||||
@@ -225,7 +225,7 @@ module.exports = function (Plugins) {
|
|||||||
|
|
||||||
pluginData.modules.forEach(function (file) {
|
pluginData.modules.forEach(function (file) {
|
||||||
if (strip) {
|
if (strip) {
|
||||||
modules[file.replace(new RegExp('\.?(\/[^\/]+){' + strip + '}\/'), '')] = path.join('./node_modules/', pluginData.id, file);
|
modules[file.replace(new RegExp('.?(/[^/]+){' + strip + '}/'), '')] = path.join('./node_modules/', pluginData.id, file);
|
||||||
} else {
|
} else {
|
||||||
modules[path.basename(file)] = path.join('./node_modules/', pluginData.id, file);
|
modules[path.basename(file)] = path.join('./node_modules/', pluginData.id, file);
|
||||||
}
|
}
|
||||||
@@ -268,13 +268,12 @@ module.exports = function (Plugins) {
|
|||||||
if (!atRootLevel && relPath) {
|
if (!atRootLevel && relPath) {
|
||||||
winston.verbose('[plugins/load] File not found: ' + fullPath + ' (Ascending)');
|
winston.verbose('[plugins/load] File not found: ' + fullPath + ' (Ascending)');
|
||||||
return resolveModulePath(path.join(__dirname, '../..', relPath));
|
return resolveModulePath(path.join(__dirname, '../..', relPath));
|
||||||
} else {
|
}
|
||||||
// Already at root level, file was simply not found
|
// Already at root level, file was simply not found
|
||||||
winston.warn('[plugins/load] File not found: ' + fullPath + ' (Ignoring)');
|
winston.warn('[plugins/load] File not found: ' + fullPath + ' (Ignoring)');
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Plugins.loadPluginInfo = function (pluginPath, callback) {
|
Plugins.loadPluginInfo = function (pluginPath, callback) {
|
||||||
async.parallel({
|
async.parallel({
|
||||||
|
|||||||
@@ -83,9 +83,8 @@ function onMessage(socket, payload) {
|
|||||||
var methodToCall = parts.reduce(function (prev, cur) {
|
var methodToCall = parts.reduce(function (prev, cur) {
|
||||||
if (prev !== null && prev[cur]) {
|
if (prev !== null && prev[cur]) {
|
||||||
return prev[cur];
|
return prev[cur];
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}, Namespaces);
|
}, Namespaces);
|
||||||
|
|
||||||
if (!methodToCall) {
|
if (!methodToCall) {
|
||||||
|
|||||||
@@ -93,9 +93,9 @@ function rateLimitExceeded(socket) {
|
|||||||
var delay = meta.config.hasOwnProperty('chatMessageDelay') ? parseInt(meta.config.chatMessageDelay, 10) : 200;
|
var delay = meta.config.hasOwnProperty('chatMessageDelay') ? parseInt(meta.config.chatMessageDelay, 10) : 200;
|
||||||
if (now - socket.lastChatMessageTime < delay) {
|
if (now - socket.lastChatMessageTime < delay) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
socket.lastChatMessageTime = now;
|
|
||||||
}
|
}
|
||||||
|
socket.lastChatMessageTime = now;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -79,9 +79,8 @@ module.exports = function (Topics) {
|
|||||||
tids = results.topicData.filter(function (topic) {
|
tids = results.topicData.filter(function (topic) {
|
||||||
if (topic) {
|
if (topic) {
|
||||||
return results.ignoredCids.indexOf(topic.cid.toString()) === -1;
|
return results.ignoredCids.indexOf(topic.cid.toString()) === -1;
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}).map(function (topic) {
|
}).map(function (topic) {
|
||||||
return topic.tid;
|
return topic.tid;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ describe('Utility Methods', function () {
|
|||||||
|
|
||||||
describe('cleanUpTag', function () {
|
describe('cleanUpTag', function () {
|
||||||
it('should cleanUp a tag', function (done) {
|
it('should cleanUp a tag', function (done) {
|
||||||
var cleanedTag = utils.cleanUpTag(',\/#!$%\^\*;TaG1:{}=_`<>\'"~()?\|');
|
var cleanedTag = utils.cleanUpTag(',/#!$%^*;TaG1:{}=_`<>\'"~()?|');
|
||||||
assert.equal(cleanedTag, 'tag1');
|
assert.equal(cleanedTag, 'tag1');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user