Problem/Motivation

if a spam word in the "reject patterns" field has å,ä or ö letters in the end or in the beginning of the word,
the word is not considered as spam and the content is saved.

Steps to reproduce

1. enable module and set latin to allowed language scripts
2. put these words in the "reject pattern" field:
ätest, ötest, €test
3. submit a form first with "ätest" word in the body field, it is saved (problem)
submit a form with "ötest" word in the body field, it is saved (problem)
submit a form with "€test" word in the body field, it is blockd (works as designed)

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Comments

Youcanlearnit created an issue. See original summary.

larisse’s picture

Status: Active » Needs review
StatusFileSize
new1.02 KB

Hi! I created a patch for this issue. I had notice that preg_match function doesn't work for check if some words is valid or not. So I made a comparation to validate the form too.
I think that isn't the better way to make this, but here is a patch.

Youcanlearnit’s picture

Hi,
Thank you very much for the patch.

I have been testing it for a while now.
It does fix the first problem mentioned in #1, if using just one word, but it does not work with longer sentences.

For example I can submit "Edit group post group post ätest" (which is a problem because the word "ätest" is in the rejected pattern)
But I can't submit "Edit group post group post testword (which is good because "testword" is in the rejected patterns)

Also I noticed that without this patch, these are not blocked "http://" or "ssl://"

altagrade’s picture

Status: Needs review » Needs work

Thanks for your inputs. Larisse, if you could please re-work the patch noting Youcanlearnit's findings?

larisse’s picture

Hi @AltaGrade! I can work on this :)

larisse’s picture

Status: Needs work » Needs review
StatusFileSize
new1.02 KB

Hi, here is a new patch. I used str_contains function to compare if the invalid word is in the phrase the user is inserting, instead of the comparison that I was doing in the patch #2.

altagrade’s picture

Status: Needs review » Needs work

Apparently the https://www.php.net/manual/en/function.str-contains.php function was introduced only on PHP 8, so to maintain the functionality of the module on previous PHP versions, we have to mark this as "needs work".

larisse’s picture

Status: Needs work » Needs review
StatusFileSize
new1.04 KB

Hi @AltaGrade, sorry!

I'm using PHP 7.4 and don't had problem to use the function, what is very stranger.
However, I looked in PHP documentation to see how the function was implementation and here is a new patch.

Youcanlearnit’s picture

Hi

Thanks larisse, #8 looking good and works for me after some testings.

gabriel.abdalla’s picture

Status: Needs review » Needs work

Hi, thanks, Larisse, issue is fixed. One additional request: there are few coding standards issues to be handled (PHPCS standards Drupal and DrupalPractice):

727 | ERROR | [x] Expected one space after the comma, 0 found
727 | ERROR | [x] Expected one space after the comma, 0 found
728 | ERROR | [x] Expected one space after the comma, 0 found
728 | ERROR | [x] Expected one space after the comma, 0 found
733 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"

I'm setting the issue status to "Needs Work" so those PHPCS changes can be handled.

larisse’s picture

Status: Needs work » Needs review
StatusFileSize
new1.05 KB

A new patch to fix phpcs errors.

larisse’s picture

gabriel.abdalla’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new9.29 KB

Hi, thanks, Larisse. Patch looks good to me. PHPCS issues were fixed.

Tested again to double check, validation message attached shown in all three strings: "ätest", "ötest" and "€test".

Moving issue to RTBC.

  • larisse authored 5a442a5 on 8.x-1.x
    Issue #3231740 by larisse, gabriel.abdalla: some characters are removed
    
altagrade’s picture

Status: Reviewed & tested by the community » Fixed

As @Youcanlearnit noted:

Also I noticed that without this patch, these are not blocked "http://" or "ssl://"

the proposed changed were too intrusive making it impossible to block links, therefore with slight changes I accepted the patch. Thank you, everyone who contributed to resolving this issue.

altagrade’s picture

Status: Fixed » Closed (fixed)