summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-banip
diff options
context:
space:
mode:
authorDirk Brenken <dev@brenken.org>2024-04-22 22:28:58 +0200
committerDirk Brenken <dev@brenken.org>2024-04-22 22:28:58 +0200
commit32babe7069c2297ae8f2578e38762b3406bc84d7 (patch)
tree21357dfd0b7bf978f05d63723a49c7b7b29b6031 /applications/luci-app-banip
parentaa463d007fcea9cd5164d7b6e678884589ca4ac2 (diff)
luci-app-banip: handle json load errors
* properly handle possible json load errors in try/catch blocks Signed-off-by: Dirk Brenken <dev@brenken.org>
Diffstat (limited to 'applications/luci-app-banip')
-rw-r--r--applications/luci-app-banip/htdocs/luci-static/resources/view/banip/overview.js16
-rw-r--r--applications/luci-app-banip/htdocs/luci-static/resources/view/banip/setreport.js14
2 files changed, 25 insertions, 5 deletions
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.'));
diff --git a/applications/luci-app-banip/htdocs/luci-static/resources/view/banip/setreport.js b/applications/luci-app-banip/htdocs/luci-static/resources/view/banip/setreport.js
index a6f8ddc0fe..f313a5efd6 100644
--- a/applications/luci-app-banip/htdocs/luci-static/resources/view/banip/setreport.js
+++ b/applications/luci-app-banip/htdocs/luci-static/resources/view/banip/setreport.js
@@ -66,7 +66,12 @@ function handleAction(report, ev) {
let content, selectOption;
if (report[1]) {
- content = JSON.parse(report[1]);
+ try {
+ content = JSON.parse(report[1]);
+ } catch (e) {
+ content = "";
+ ui.addNotification(null, E('p', _('Unable to parse the ruleset file: %s').format(e.message)), 'error');
+ }
} else {
content = "";
}
@@ -140,7 +145,12 @@ return view.extend({
let content, rowSets, tblSets;
if (report[0]) {
- content = JSON.parse(report[0]);
+ try {
+ content = JSON.parse(report[0]);
+ } catch (e) {
+ content = "";
+ ui.addNotification(null, E('p', _('Unable to parse the report file: %s').format(e.message)), 'error');
+ }
} else {
content = "";
}