Skip to content

Node.js based forum software built for the modern web

fix: prevent crash if groups is not valid json

Barış Soner Uşaklıcc0a087a709c
diff --git a/src/navigation/admin.js b/src/navigation/admin.js
index 19193abdc7..e4221bf156 100644
--- a/src/navigation/admin.js
+++ b/src/navigation/admin.js
@@ -1,6 +1,7 @@
'use strict';
const validator = require('validator');
+const winston = require('winston');
const plugins = require('../plugins');
const db = require('../database');
@@ -66,7 +67,12 @@ admin.get = async function () {
const data = await db.getObjects(ids.map(id => `navigation:enabled:${id}`));
cache = data.map((item) => {
if (item.hasOwnProperty('groups')) {
- item.groups = JSON.parse(item.groups);
+ try {
+ item.groups = JSON.parse(item.groups);
+ } catch (err) {
+ winston.error(err.stack);
+ item.groups = [];
+ }
}
item.groups = item.groups || [];
if (item.groups && !Array.isArray(item.groups)) {