Skip to content

Commit

Permalink
[BUGFIX] Skip boolean values in blacklist string check
Browse files Browse the repository at this point in the history
Thx to @christophlehmann for the PR

Related: #646
  • Loading branch information
mschwemer committed Sep 25, 2024
1 parent 40a6eb3 commit b0a8165
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
5 changes: 0 additions & 5 deletions .project/tests/phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -2510,11 +2510,6 @@ parameters:
count: 1
path: ../../Classes/Domain/Validator/SpamShield/ValueBlacklistMethod.php

-
message: "#^Cannot call method getValue\\(\\) on object\\|null\\.$#"
count: 2
path: ../../Classes/Domain/Validator/SpamShield/ValueBlacklistMethod.php

-
message: "#^Method In2code\\\\Powermail\\\\Domain\\\\Validator\\\\SpamShield\\\\ValueBlacklistMethod\\:\\:getValues\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
Expand Down
7 changes: 6 additions & 1 deletion Classes/Domain/Validator/SpamShield/ValueBlacklistMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
declare(strict_types=1);
namespace In2code\Powermail\Domain\Validator\SpamShield;

use In2code\Powermail\Domain\Model\Answer;
use In2code\Powermail\Utility\ObjectUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;

Expand All @@ -23,12 +24,16 @@ class ValueBlacklistMethod extends AbstractMethod
*/
public function spamCheck(): bool
{
/** @var Answer $answer */
foreach ($this->mail->getAnswers() as $answer) {
if (is_array($answer->getValue())) {
continue;
}
if (is_bool($answer->getValue())) {
continue;
}
foreach ($this->getValues() as $blackword) {
if ($this->isStringInString($answer->getValue(), $blackword)) {
if ($this->isStringInString((string)$answer->getValue(), $blackword)) {
return true;
}
}
Expand Down

0 comments on commit b0a8165

Please sign in to comment.