From 4fcdc94174aaf514fa5e7b77dd4d8b6cbec97d4c Mon Sep 17 00:00:00 2001
From: Davide <davide@suma-ev.de>
Date: Wed, 14 Oct 2020 12:38:25 +0200
Subject: [PATCH] added cookie black list to search

---
 app/Http/Controllers/SettingsController.php |  2 +-
 app/MetaGer.php                             | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/app/Http/Controllers/SettingsController.php b/app/Http/Controllers/SettingsController.php
index f22ee7d9c..ad8402ff2 100644
--- a/app/Http/Controllers/SettingsController.php
+++ b/app/Http/Controllers/SettingsController.php
@@ -281,7 +281,7 @@ class SettingsController extends Controller
             $blacklist = substr($blacklist, 0, stripos($blacklist, '/'));
         }
 
-        $regexUrl = '#^[a-z0-9.]*$#';
+        $regexUrl = '#^(\*\.)?[a-z0-9.]*$#';
         if(preg_match($regexUrl, $blacklist) == 1){
 
             $path = \Request::path();
diff --git a/app/MetaGer.php b/app/MetaGer.php
index 84dbfe058..5c856dec5 100644
--- a/app/MetaGer.php
+++ b/app/MetaGer.php
@@ -5,6 +5,7 @@ namespace App;
 use App;
 use Cache;
 use Carbon;
+use Cookie;
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\Redis;
 use Jenssegers\Agent\Agent;
@@ -1352,6 +1353,14 @@ class MetaGer
             }
         }
 
+        foreach(Cookie::get() as $key => $value){
+            if(stripos($key, 'blpage') !== false && stripos($value, '*.') === false){
+                $this->hostBlacklist[] = $value;
+            }
+        }
+
+        array_unique($this->hostBlacklist);
+
         // print the host blacklist as a user warning
         if (sizeof($this->hostBlacklist) > 0) {
             $hostString = "";
@@ -1386,6 +1395,15 @@ class MetaGer
                 $this->domainBlacklist[] = substr($blacklistString, strpos($blacklistString, "*.") + 2);
             }
         }
+
+        foreach(Cookie::get() as $key => $value){
+            if(stripos($key, 'blpage') !== false && stripos($value, '*.') !== false){
+                $this->domainBlacklist[] = $value;
+            }
+        }
+
+        array_unique($this->domainBlacklist);
+
         // print the domain blacklist as a user warning
         if (sizeof($this->domainBlacklist) > 0) {
             $domainString = "";
-- 
GitLab