diff --git a/README.md b/README.md index 6348ec3..24d8af8 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,7 @@ Also thanks to [LudoBoggio](https://github.com/LudoBoggio) for the [YourlsBlackl --------- +v0.05 Fix all links being blocked v0.04 Fix https and not both https and http blocking v0.03 Fix some crap code (of mine) v0.02 Cosmetic changes diff --git a/plugin.php b/plugin.php index fc8011e..9554725 100644 --- a/plugin.php +++ b/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