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
Comment #2
larisse commentedHi! 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.
Comment #3
Youcanlearnit commentedHi,
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://"
Comment #4
altagrade commentedThanks for your inputs. Larisse, if you could please re-work the patch noting Youcanlearnit's findings?
Comment #5
larisse commentedHi @AltaGrade! I can work on this :)
Comment #6
larisse commentedHi, 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.
Comment #7
altagrade commentedApparently 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".
Comment #8
larisse commentedHi @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.
Comment #9
Youcanlearnit commentedHi
Thanks larisse, #8 looking good and works for me after some testings.
Comment #10
gabriel.abdalla commentedHi, 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.
Comment #11
larisse commentedA new patch to fix phpcs errors.
Comment #12
larisse commentedComment #13
gabriel.abdalla commentedHi, 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.
Comment #15
altagrade commentedAs @Youcanlearnit noted:
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.
Comment #16
altagrade commented