From 0973965c527d5dee326dff0a5ed0d921edbd2e7c Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 19 Oct 2026 15:23:38 +0000 Subject: [PATCH] Store the addresses and networks of the block and allow list in canonical form The plugin looks the visitor up in these lists by the canonical spelling of the entries (IpHelper::canonicalEntry()): "2001:DB8::1" is stored as "2001:db8::1", "203.0.113.77/24" as "203.0.113.0/24". The tests are in the bfstop repository (branch cidr-lookup-cost). Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01LhhhdjhErC9ZiaS4HyRjsh --- admin/src/Table/AllowTable.php | 9 +++++++++ admin/src/Table/BlockTable.php | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/admin/src/Table/AllowTable.php b/admin/src/Table/AllowTable.php index 00af5bf..d63ecc6 100644 --- a/admin/src/Table/AllowTable.php +++ b/admin/src/Table/AllowTable.php @@ -10,6 +10,7 @@ defined('_JEXEC') or die; +use Codeling\Plugin\System\Bfstop\Helper\IpHelper; use Joomla\CMS\Table\Table; use Joomla\Database\DatabaseDriver; @@ -30,6 +31,14 @@ public function check() { $this->id = 0; } + // addresses and networks are looked up by their canonical spelling, see + // IpHelper::canonicalEntry() ("2001:DB8::1" and "203.0.113.5/24" are + // kept as "2001:db8::1" and "203.0.113.0/24") + $canonical = IpHelper::canonicalEntry($this->ipaddress); + if ($canonical !== null) + { + $this->ipaddress = $canonical; + } return parent::check(); } } diff --git a/admin/src/Table/BlockTable.php b/admin/src/Table/BlockTable.php index 0f6668f..0301094 100644 --- a/admin/src/Table/BlockTable.php +++ b/admin/src/Table/BlockTable.php @@ -10,6 +10,7 @@ defined('_JEXEC') or die; +use Codeling\Plugin\System\Bfstop\Helper\IpHelper; use Joomla\CMS\Table\Table; use Joomla\Database\DatabaseDriver; @@ -30,6 +31,14 @@ public function check() { $this->id = 0; } + // addresses and networks are looked up by their canonical spelling, see + // IpHelper::canonicalEntry() ("2001:DB8::1" and "203.0.113.5/24" are + // kept as "2001:db8::1" and "203.0.113.0/24") + $canonical = IpHelper::canonicalEntry($this->ipaddress); + if ($canonical !== null) + { + $this->ipaddress = $canonical; + } return parent::check(); } }