From bd050d27c445a597800fed508a4f11784b1254d0 Mon Sep 17 00:00:00 2001 From: Maingron Date: Sat, 13 Sep 2025 02:11:39 +0200 Subject: [PATCH] Add possible regex handling --- plugin.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/plugin.php b/plugin.php index b557ce7..8d6366d 100644 --- a/plugin.php +++ b/plugin.php @@ -45,10 +45,17 @@ function better_blacklist_domain_check( $shunt, $url ) { $blacklisted_domains = unserialize( $blacklisted_domains ); foreach ( $blacklisted_domains as $blacklisted_domain ) { - // Use a regex to match the domain or subdomain - $pattern = '/(?:^|\.)' . preg_quote( $blacklisted_domain, '/' ) . '$/i'; - if ( preg_match( $pattern, $domain ) ) { - return blacklist_fail_response(); + // Check if the entry starts with '/', then consider regex handling + if (strpos($blacklisted_domain, '/') === 0) { + if (@preg_match($blacklisted_domain, $domain)) { + return blacklist_fail_response(); + } + } else { + // Otherwise treat as plain domain (old behavior) + $pattern = '/(?:^|\.)' . preg_quote( $blacklisted_domain, '/' ) . '$/i'; + if ( preg_match( $pattern, $domain ) ) { + return blacklist_fail_response(); + } } } } @@ -126,4 +133,4 @@ function better_blacklist_process_form() { } echo ""; } -} \ No newline at end of file +}