wp-ban icon indicating copy to clipboard operation
wp-ban copied to clipboard

Case insensitive match when blocking user agents

Open silv3rm00n opened this issue 8 years ago • 1 comments

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.

silv3rm00n avatar Jun 01 '17 03:06 silv3rm00n

sent a Pull Request? I will merge it. I think it makes sense to have case insensitive match.

lesterchan avatar Jun 01 '17 03:06 lesterchan