wp-ban
wp-ban copied to clipboard
Case insensitive match when blocking user agents
When blocking by user agent, it would be ideal to do case insensitive match, or may be add an option to select case insensitive match in admin panel.
So if I specify "AskBot" in the user agent list, it should block "askbot" "askBot" "askBOT" all of them.
For now, I modified the code, function preg_match_wildcard($regex, $subject) { $regex = preg_quote($regex, '#'); $regex = str_replace('*', '.*', $regex); if(preg_match("#^$regex$#i", $subject)) { return true; } else { return false; } }
The call to preg_match has a "i" modifier attached to it.
sent a Pull Request? I will merge it. I think it makes sense to have case insensitive match.