Partial word are also blocked

Created on 20 March 2025, 17 days ago

Problem/Motivation

The check for spam words returning false positives should only flag exact matches, not words that contain the target word. For example, 'SEO' should be blocked, but 'SEOul' (the capital of South Korea 😉) should not.

Steps to reproduce

  1. Enable the module and configure the handler in webform
  2. Add SEO as spam word
  3. Go to the webform write "SEOul is the capital of South Korea "
  4. submit

Proposed resolution

this condition if (strpos($value, mb_strtolower(trim($word))) !== FALSE) will return true in the SEO vs SEOul case.

It's better to add a check for exact word something like

protected function isExactWordExist(string $phrase, string $word): bool {
    // Trim and lowercase the word for comparison.
    $word = mb_strtolower(trim($word));
    $phrase = mb_strtolower($phrase);

    // Use regex with word boundaries to check for the exact word.
    return preg_match("/\b" . preg_quote($word, '/') . "\b/", $phrase) === 1;
  }

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

3.0

Component

Code

Created by

🇫🇷France berramou

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024