Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Case insensitive match when blocking user agents #9

Open
silv3rm00n opened this issue Jun 1, 2017 · 1 comment
Open

Case insensitive match when blocking user agents #9

silv3rm00n opened this issue Jun 1, 2017 · 1 comment

Comments

@silv3rm00n
Copy link

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.

@lesterchan
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants