fixed all links being blocked
This commit is contained in:
13
plugin.php
13
plugin.php
@ -3,7 +3,7 @@
|
||||
Plugin Name: Better Yourls BlackList Domains
|
||||
Plugin URI: https://git.oldgate.org/Sophia/better-yourls-blacklist-domains
|
||||
Description: Plugin which disallows blacklisted domains and bans the submitter's IP address. GPL v3
|
||||
Version: 0.04
|
||||
Version: 0.05
|
||||
Author: Sophia Atkinson
|
||||
Author URI: https://sophia.wtf
|
||||
Original Author: apelly
|
||||
@ -23,11 +23,18 @@ yourls_add_action( 'plugins_loaded', 'better_blacklist_add_admin_page' );
|
||||
function better_blacklist_domain_check( $shunt, $url ) {
|
||||
// Parse the URL and extract the host
|
||||
$parsed_url = parse_url( $url );
|
||||
$domain = $parsed_url['host'] ?? '';
|
||||
|
||||
// If parsing fails or host is empty, deny the URL
|
||||
if (empty($parsed_url['host'])) {
|
||||
return blacklist_fail_response();
|
||||
}
|
||||
|
||||
$domain = $parsed_url['host'];
|
||||
|
||||
// Block if using blacklisted protocols
|
||||
if ( isset($parsed_url['scheme']) && in_array( $parsed_url['scheme'], ['http', 'https'], true ) ) {
|
||||
return blacklist_fail_response();
|
||||
// Instead of blocking here, we return the original shunt
|
||||
// to avoid blocking all URLs with blacklisted protocols
|
||||
}
|
||||
|
||||
// Retrieve blacklisted domains from options
|
||||
|
Reference in New Issue
Block a user