I have a words blacklist rule that matches the word "and" in the first name to keep people from trying to register more than one person on a single form. However, I got a complaint about a registration being rejected and the first name field being highlighted in red when someone named "Wanda" tried to register.
I think the words blacklist rule is matching to a pattern instead of a word.
case "blacklist":
$blacklist = explode(',', $rule['data']);
$blacklist = array_map('trim', $blacklist);
$blacklist_regex = implode('|', $blacklist);
foreach ($items as $key => $val) {
if ($val != '' && (preg_match("/$blacklist_regex/i", $val))) {
$errors[$key] = _webform_validation_i18n_error_message($rule);
}
}
return $errors;
break;
It think you need to add "\b"`s around to the regex pattern to do a word matching:
preg_match("/\b$blacklist_regex\b/i", $val)
Comments
Comment #1
creeksideplayers commentedCorrection, that should be
Comment #2
svendecabooterGood catch.
I'll have to test it some more, and think about the upgrade path for people that are already relying on the other behaviour...
Comment #3
DrewMathers commentedPerhaps you could provide a checkbox providing the option to match only whole words.
Comment #4
liam morlandThis change is backwards-incompatible; it will now match full words as documented, not patterns.
Fixed in 7841911.
Comment #5
liam morlandComment #6
liam morlandTwo more patches to make this actually work and migrate from the need to escape regex characters.
Comment #7
liam morlandCommitted in:
42b0989e8f7b9af71565f727995ee09d021d1215
ef372f66813fd3db1f3b2d679b4af5163579e08d
Comment #8
liam morlandComment #9
liam morlandDrupal 6 is no longer supported.