From 32babe7069c2297ae8f2578e38762b3406bc84d7 Mon Sep 17 00:00:00 2001 From: Dirk Brenken Date: Mon, 22 Apr 2024 22:28:58 +0200 Subject: luci-app-banip: handle json load errors * properly handle possible json load errors in try/catch blocks Signed-off-by: Dirk Brenken --- .../htdocs/luci-static/resources/view/banip/overview.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'applications/luci-app-banip/htdocs/luci-static/resources/view/banip/overview.js') diff --git a/applications/luci-app-banip/htdocs/luci-static/resources/view/banip/overview.js b/applications/luci-app-banip/htdocs/luci-static/resources/view/banip/overview.js index 5ebf25855d..c8c571f735 100644 --- a/applications/luci-app-banip/htdocs/luci-static/resources/view/banip/overview.js +++ b/applications/luci-app-banip/htdocs/luci-static/resources/view/banip/overview.js @@ -11,7 +11,7 @@ button handling */ function handleAction(ev) { - fs.exec_direct('/etc/init.d/banip', [ev]) + return fs.exec_direct('/etc/init.d/banip', [ev]) } return view.extend({ @@ -472,9 +472,19 @@ return view.extend({ let feed, feeds, descr; if (result[0]) { - feeds = JSON.parse(result[0]); + try { + feeds = JSON.parse(result[0]); + } catch (e) { + feeds = ""; + ui.addNotification(null, E('p', _('Unable to parse the custom feed file: %s').format(e.message)), 'error'); + } } else if (result[1]) { - feeds = JSON.parse(result[1]); + try { + feeds = JSON.parse(result[1]); + } catch (e) { + feeds = ""; + ui.addNotification(null, E('p', _('Unable to parse the default feed file: %s').format(e.message)), 'error'); + } } if (feeds) { o = s.taboption('adv_set', form.MultiValue, 'ban_blockinput', _('WAN-Input Chain'), _('Limit certain feeds to the WAN-Input chain.')); -- cgit v1.2.3