From a299353dce231447309a5225e47427168253249e Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 19 Feb 2024 02:26:21 +0000 Subject: [PATCH] Avoid problems with an empty domain in the blocklist --- src/Module/Moderation/Blocklist/Server/Index.php | 5 +++-- src/Util/Network.php | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Module/Moderation/Blocklist/Server/Index.php b/src/Module/Moderation/Blocklist/Server/Index.php index 740d7b05d2..0ff90eeaee 100644 --- a/src/Module/Moderation/Blocklist/Server/Index.php +++ b/src/Module/Moderation/Blocklist/Server/Index.php @@ -57,11 +57,11 @@ class Index extends BaseModeration // Edit the entries from blocklist $blocklist = []; - foreach ($request['domain'] as $id => $domain) { + foreach ((array)$request['domain'] as $id => $domain) { // Trimming whitespaces as well as any lingering slashes $domain = trim($domain); $reason = trim($request['reason'][$id]); - if (empty($request['delete'][$id])) { + if (empty($request['delete'][$id]) && !empty($domain)) { $blocklist[] = [ 'domain' => $domain, 'reason' => $reason @@ -69,6 +69,7 @@ class Index extends BaseModeration } } + $this->logger->debug('Blubb', ['blocklist' => $blocklist]); $this->blocklist->set($blocklist); Worker::add(Worker::PRIORITY_LOW, 'UpdateBlockedServers'); diff --git a/src/Util/Network.php b/src/Util/Network.php index 02124a4e71..12dde0a3db 100644 --- a/src/Util/Network.php +++ b/src/Util/Network.php @@ -217,7 +217,7 @@ class Network } foreach ($domain_blocklist as $domain_block) { - if (fnmatch(strtolower($domain_block['domain']), strtolower($uri->getHost()))) { + if (!empty($domain_block['domain']) && fnmatch(strtolower($domain_block['domain']), strtolower($uri->getHost()))) { return true; } }