From cb294cf411ee8843096497e017d309b6005c276a Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Mon, 19 Feb 2024 07:22:19 +0100 Subject: [PATCH] Avoid problems with an empty domain in the blocklist (#13919) * Avoid problems with an empty domain in the blocklist * Test code removed --- src/Module/Moderation/Blocklist/Server/Index.php | 4 ++-- src/Util/Network.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Module/Moderation/Blocklist/Server/Index.php b/src/Module/Moderation/Blocklist/Server/Index.php index 740d7b05d2..3b6dc735dd 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 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; } }