From ada92c9590fd7ad3d6e0032be58e84c27c73d631 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Phil=20H=C3=B6fer?= <phil.hoefer@suma-ev.de> Date: Mon, 24 Jun 2024 09:38:47 +0000 Subject: [PATCH] Allow some use of comments in url blocklist file --- metager/app/MetaGer.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/metager/app/MetaGer.php b/metager/app/MetaGer.php index 56762787d..b178a5ff4 100644 --- a/metager/app/MetaGer.php +++ b/metager/app/MetaGer.php @@ -89,17 +89,23 @@ class MetaGer public function __construct($hash = "") { - # Timer starten + # start timer $this->starttime = microtime(true); - # Versuchen Blacklists einzulesen + # Read blocklists if (file_exists(config_path() . "/blacklistDomains.txt") && file_exists(config_path() . "/blacklistUrl.txt")) { $tmp = file_get_contents(config_path() . "/blacklistDomains.txt"); $this->domainsBlacklisted = explode("\n", $tmp); $tmp = file_get_contents(config_path() . "/blacklistUrl.txt"); - $this->urlsBlacklisted = explode("\n", $tmp); + $lines = explode("\n", $tmp); + $filtered_lines = array_filter($lines, function($line) { + return strpos(trim($line), '#') !== 0; + }); + # Re-index the array (array_filter preserves keys by default) + $filtered_lines = array_values($filtered_lines); + $this->urlsBlacklisted = $filtered_lines; } - # Versuchen Blacklists einzulesen + # Read blocklists if (file_exists(config_path() . "/adBlacklistDomains.txt")) { $tmp = file_get_contents(config_path() . "/adBlacklistDomains.txt"); $this->adDomainsBlacklisted = explode("\n", $tmp); -- GitLab