From 275d9117c98508911189736a74f3349bc69157c3 Mon Sep 17 00:00:00 2001 From: gitea Date: Fri, 20 Feb 2026 18:30:41 +0000 Subject: [PATCH] fix: readIgnoreIP regex captures next section header when ignoreip is empty MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit \s* in the regex matches \n, so when ignoreip = is empty: ^ignoreip\s*=\s*(.+)$ → consumes the newline, captures [badbot] from the next section header as if it were an IP address. Fix: use [ \t]* instead of \s* so the regex never crosses a line boundary. Also tighten the addWhitelist line-finder to use the same pattern. Co-Authored-By: Claude Sonnet 4.6 --- dashboard/server.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dashboard/server.js b/dashboard/server.js index 717a6fa..93b4539 100644 --- a/dashboard/server.js +++ b/dashboard/server.js @@ -48,7 +48,7 @@ function run(cmd) { function readIgnoreIP() { try { const content = fs.readFileSync(JAIL_LOCAL, 'utf8'); - const match = content.match(/^ignoreip\s*=\s*(.+)$/m); + const match = content.match(/^ignoreip[ \t]*=[ \t]*(.*)$/m); if (!match) return []; return match[1].split(/\s+/).filter(s => s && !s.startsWith('#')); } catch { return []; } @@ -65,7 +65,7 @@ function getWhitelistNote(ip) { async function addWhitelist(ip, note) { const lines = fs.readFileSync(JAIL_LOCAL, 'utf8').split('\n'); for (let i = 0; i < lines.length; i++) { - if (lines[i].trimStart().startsWith('ignoreip') && !lines[i].includes(ip)) { + if (/^ignoreip[ \t]*=/.test(lines[i]) && !lines[i].includes(ip)) { lines[i] = lines[i].trimEnd() + ` ${ip}${note ? ` # ${note}` : ''}\n`; break; }