luci-app-adblock: update 4.5.5-6
authorDirk Brenken <redacted>
Tue, 26 May 2026 15:19:57 +0000 (17:19 +0200)
committerDirk Brenken <redacted>
Tue, 26 May 2026 15:20:55 +0000 (17:20 +0200)
* sync with base package

Signed-off-by: Dirk Brenken <redacted>
applications/luci-app-adblock/Makefile
applications/luci-app-adblock/htdocs/luci-static/resources/view/adblock/dnsreport.js
applications/luci-app-adblock/htdocs/luci-static/resources/view/adblock/overview.js

index 6876ef41832fb976c7780c29485b1710e03fdb6e..4502af77924ef2dcd82edf82b28c93b4337fc143 100644 (file)
@@ -7,7 +7,7 @@ LUCI_TITLE:=LuCI support for Adblock
 LUCI_DEPENDS:=+luci-base +luci-lib-uqr +adblock
 
 PKG_VERSION:=4.5.5
-PKG_RELEASE:=5
+PKG_RELEASE:=6
 PKG_LICENSE:=Apache-2.0
 PKG_MAINTAINER:=Dirk Brenken <dev@brenken.org>
 
index 08933800ca0c05511a965f5392be1ad7935895b9..ff23e6021ec912aaa981eb36d29c807ef9efcc4b 100644 (file)
@@ -29,9 +29,16 @@ function handleAction(ev) {
                                E('button', {
                                        'class': 'btn cbi-button-action',
                                        'click': ui.createHandlerFn(this, function (ev) {
+                                               const domain = document.getElementById('blocklist').value.trim().toLowerCase();
+                                               if (!domain
+                                                       || domain.length > 253
+                                                       || /[^a-z0-9.-]|^-|-$|\.\.|\.$/.test(domain)) {
+                                                       ui.addNotification(null, E('p', _('Invalid input, please submit a single valid (sub-)domain.')), 'warning');
+                                                       ui.hideModal();
+                                                       return;
+                                               }
                                                L.resolveDefault(fs.read_direct('/etc/adblock/adblock.blocklist'), '')
                                                        .then(function (res) {
-                                                               const domain = document.getElementById('blocklist').value.trim().toLowerCase().replace(/[^a-z0-9.-]/g, '');
                                                                const pattern = new RegExp('^' + domain.replace(/[.]/g, '\\.') + '$', 'm');
                                                                if (res.search(pattern) === -1) {
                                                                        const blocklist = res + domain + '\n';
@@ -67,9 +74,16 @@ function handleAction(ev) {
                                E('button', {
                                        'class': 'btn cbi-button-action',
                                        'click': ui.createHandlerFn(this, function (ev) {
+                                               const domain = document.getElementById('allowlist').value.trim().toLowerCase();
+                                               if (!domain
+                                                       || domain.length > 253
+                                                       || /[^a-z0-9.-]|^-|-$|\.\.|\.$/.test(domain)) {
+                                                       ui.addNotification(null, E('p', _('Invalid input, please submit a single valid (sub-)domain.')), 'warning');
+                                                       ui.hideModal();
+                                                       return;
+                                               }
                                                L.resolveDefault(fs.read_direct('/etc/adblock/adblock.allowlist'), '')
                                                        .then(function (res) {
-                                                               const domain = document.getElementById('allowlist').value.trim().toLowerCase().replace(/[^a-z0-9.-]/g, '');
                                                                const pattern = new RegExp('^' + domain.replace(/[.]/g, '\\.') + '$', 'm');
                                                                if (res.search(pattern) === -1) {
                                                                        const allowlist = res + domain + '\n';
@@ -116,44 +130,54 @@ function handleAction(ev) {
                        E('div', { 'class': 'right' }, [
                                E('button', {
                                        'class': 'btn cbi-button',
-                                       'click': ui.hideModal
+                                       'click': function () {
+                                               if (window._adbSearchPoller) {
+                                                       clearInterval(window._adbSearchPoller);
+                                                       window._adbSearchPoller = null;
+                                               }
+                                               ui.hideModal();
+                                       }
                                }, _('Cancel')),
                                ' ',
                                E('button', {
                                        'class': 'btn cbi-button-action',
                                        'click': ui.createHandlerFn(this, function (ev) {
                                                const domain = document.getElementById('search').value.trim().toLowerCase().replace(/[^a-z0-9.-]/g, '');
-                                               if (domain) {
-                                                       document.getElementById('run').classList.add("spinning");
-                                                       document.getElementById('search').value = domain;
-                                                       document.getElementById('result').textContent = _('The search is running, please wait...');
-
-                                                       if (window._adbSearchPoller) {
-                                                               clearInterval(window._adbSearchPoller);
-                                                               window._adbSearchPoller = null;
-                                                       }
-                                                       L.resolveDefault(fs.write('/var/run/adblock/adblock.search', ''), '').then(function () {
-                                                               L.resolveDefault(fs.exec_direct('/etc/init.d/adblock', ['search', domain]), '');
-                                                               let attempts = 0;
-                                                               window._adbSearchPoller = setInterval(function () {
-                                                                       attempts++;
-                                                                       L.resolveDefault(fs.read('/var/run/adblock/adblock.search'), '').then(function (res) {
-                                                                               if (res && res.trim()) {
-                                                                                       clearInterval(window._adbSearchPoller);
-                                                                                       window._adbSearchPoller = null;
-                                                                                       document.getElementById('result').textContent = res.trim();
-                                                                                       document.getElementById('run').classList.remove("spinning");
-                                                                                       document.getElementById('search').value = '';
-                                                                               } else if (attempts >= 40) {
-                                                                                       clearInterval(window._adbSearchPoller);
-                                                                                       window._adbSearchPoller = null;
-                                                                                       document.getElementById('result').textContent = _('No Search results!');
-                                                                                       document.getElementById('run').classList.remove("spinning");
-                                                                               }
-                                                                       });
-                                                               }, 3000);
-                                                       });
+                                               document.getElementById('run').classList.add("spinning");
+                                               document.getElementById('search').value = domain;
+                                               document.getElementById('result').textContent = _('The search is running, please wait...');
+
+                                               const modal = ev.target.closest('.modal');
+                                               const buttons = modal ? modal.querySelectorAll('button') : [];
+                                               buttons.forEach(function (btn) { btn.disabled = true; });
+
+                                               if (window._adbSearchPoller) {
+                                                       clearInterval(window._adbSearchPoller);
+                                                       window._adbSearchPoller = null;
                                                }
+                                               L.resolveDefault(fs.write('/var/run/adblock/adblock.search', ''), '').then(function () {
+                                                       L.resolveDefault(fs.exec_direct('/etc/init.d/adblock', ['search', domain]), '');
+                                                       let attempts = 0;
+                                                       window._adbSearchPoller = setInterval(function () {
+                                                               attempts++;
+                                                               L.resolveDefault(fs.read('/var/run/adblock/adblock.search'), '').then(function (res) {
+                                                                       if (res && res.trim()) {
+                                                                               clearInterval(window._adbSearchPoller);
+                                                                               window._adbSearchPoller = null;
+                                                                               document.getElementById('result').textContent = res.trim();
+                                                                               document.getElementById('run').classList.remove("spinning");
+                                                                               document.getElementById('search').value = '';
+                                                                               buttons.forEach(function (btn) { btn.disabled = false; });
+                                                                       } else if (attempts >= 60) {
+                                                                               clearInterval(window._adbSearchPoller);
+                                                                               window._adbSearchPoller = null;
+                                                                               document.getElementById('result').textContent = _('No Search results!');
+                                                                               document.getElementById('run').classList.remove("spinning");
+                                                                               buttons.forEach(function (btn) { btn.disabled = false; });
+                                                                       }
+                                                               });
+                                                       }, 3000);
+                                               });
                                                document.getElementById('search').focus();
                                        })
                                }, _('Search'))
@@ -205,9 +229,8 @@ function handleAction(ev) {
                                        'id': 'refresh',
                                        'class': 'btn cbi-button-action',
                                        'click': function () {
-                                               document.querySelectorAll('.cbi-page-actions button').forEach(function (btn) {
-                                                       btn.disabled = true;
-                                               });
+                                               document.querySelectorAll('.cbi-page-actions button').forEach(b => b.disabled = true);
+                                               document.querySelectorAll('.modal .right button').forEach(b => b.disabled = true);
                                                this.blur();
                                                this.classList.add('spinning');
                                                const top_count = document.getElementById('top_count').value;
@@ -229,10 +252,8 @@ function handleAction(ev) {
                                                                                attempts++;
                                                                                if (attempts >= 10) {
                                                                                        clearInterval(poller);
-                                                                                       document.querySelectorAll('.cbi-page-actions button').forEach(function (btn) {
-                                                                                               btn.disabled = false;
-                                                                                       });
-                                                                                       document.getElementById('refresh').classList.remove('spinning');
+                                                                                       ui.hideModal();
+                                                                                       document.querySelectorAll('.cbi-page-actions button').forEach(b => b.disabled = false);
                                                                                        ui.addNotification(null, E('p', _('Failed to generate adblock report!')), 'error');
                                                                                }
                                                                        }
@@ -263,7 +284,7 @@ function handleAction(ev) {
                                        'class': 'btn cbi-button',
                                        'click': ui.createHandlerFn(this, function (ev) {
                                                ui.hideModal();
-                                               sessionStorage.clear();
+                                               sessionStorage.removeItem('mapData');
                                                location.reload();
                                        })
                                }, _('Cancel')),
@@ -482,7 +503,9 @@ return view.extend({
                }
 
                /* Draw Pie Chart with Tooltip */
-               const tooltipEl = E('div', {
+               let tooltipEl = document.getElementById('dnsPieTooltip');
+               if (tooltipEl) tooltipEl.remove();
+               tooltipEl = E('div', {
                        id: 'dnsPieTooltip',
                        style: 'position:absolute; padding:6px 10px; background:#333; color:#fff; border-radius:4px; font-size:12px; pointer-events:none; opacity:0; transition:opacity .15s; z-index:9999'
                });
index 453cd03e5a30e6c021ad32b1d3ae3af79f14ca44..e422063ee0dbd1d50d3086cdcdb9c5fc31ebce3d 100644 (file)
@@ -97,16 +97,14 @@ return view.extend({
                                        } catch (e) {
                                                info = null;
                                                parseErrCount++;
+                                               if (parseErrCount >= 5) {
+                                                       ui.addNotification(null, E('p', _('Unable to parse the adblock runtime information!')), 'error');
+                                                       poll.stop();
+                                               }
                                                if (status) {
                                                        status.textContent = '-';
-                                                       buttons.forEach(function (btn) {
-                                                               btn.disabled = false;
-                                                       });
+                                                       buttons.forEach(btn => btn.disabled = false);
                                                        status.classList.remove('spinning');
-                                                       if (parseErrCount >= 5) {
-                                                               ui.addNotification(null, E('p', _('Unable to parse the adblock runtime information!')), 'error');
-                                                               poll.stop();
-                                                       }
                                                }
                                                return;
                                        }
@@ -122,13 +120,10 @@ return view.extend({
                                                        }
                                                } else {
                                                        status.classList.remove("spinning");
-                                                       if (document.getElementById('btn_suspend')) {
-                                                               if (info.adblock_status === 'paused') {
-                                                                       document.querySelector('#btn_suspend').textContent = 'Resume';
-                                                               }
-                                                               if (info.adblock_status === 'enabled') {
-                                                                       document.querySelector('#btn_suspend').textContent = 'Suspend';
-                                                               }
+                                                       const btnSuspend = document.getElementById('btn_suspend');
+                                                       if (btnSuspend) {
+                                                               if (info.adblock_status === 'paused') btnSuspend.textContent = _('Resume');
+                                                               if (info.adblock_status === 'enabled') btnSuspend.textContent = _('Suspend');
                                                        }
                                                        buttons.forEach(function (btn) {
                                                                btn.disabled = false;
@@ -153,7 +148,7 @@ return view.extend({
                        runtime information and buttons
                */
                s = m.section(form.NamedSection, 'global');
-               s.render = L.bind(function (view, section_id) {
+               s.render = function (view, section_id) {
                        return E('div', { 'class': 'cbi-section' }, [
                                E('h3', _('Information')),
                                E('div', { 'class': 'cbi-value' }, [
@@ -193,7 +188,7 @@ return view.extend({
                                        E('div', { 'class': 'cbi-value-field', 'id': 'sys', 'style': 'margin-bottom:-5px;color:#37c;' }, '-')
                                ])
                        ]);
-               }, o, this);
+               };
 
                /*
                        tabbed config section
@@ -703,7 +698,7 @@ return view.extend({
                /*
                        feed selection tab
                */
-               let chain, descr;
+               let size, descr;
                let feeds = null;
 
                if (result[0] && result[0].trim() !== "") {
@@ -731,9 +726,9 @@ return view.extend({
                        o = s.taboption('feeds', form.MultiValue, 'adb_feed', _('Blocklist Feed'));
                        const feedKeys = Object.keys(feeds);
                        for (const feed of feedKeys) {
-                               chain = feeds[feed].size?.trim() || 'in';
-                               descr = feeds[feed].descr?.trim() || '-';
-                               o.value(feed.trim(), feed.trim() + ' (' + chain + ', ' + descr + ')');
+                               size = String(feeds[feed].size ?? '').trim() || '-';
+                               descr = String(feeds[feed].descr ?? '').trim() || '-';
+                               o.value(feed.trim(), feed.trim() + ' (' + size + ', ' + descr + ')');
                        }
                        o.optional = true;
                        o.rmempty = true;
@@ -803,7 +798,7 @@ return view.extend({
                        action buttons
                */
                s = m.section(form.NamedSection, 'global');
-               s.render = L.bind(function () {
+               s.render = function () {
                        return E('div', { 'class': 'cbi-page-actions' }, [
                                E('button', {
                                        'class': 'btn cbi-button cbi-button-negative important',
@@ -839,7 +834,7 @@ return view.extend({
                                        }
                                }, [_('Save & Restart')])
                        ]);
-               });
+               };
                return m.render();
        },
        handleSaveApply: null,
git clone https://git.99rst.org/PROJECT