Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty line in words list matches every post #51

Open
clarkwinkelmann opened this issue Apr 29, 2024 · 0 comments
Open

Empty line in words list matches every post #51

clarkwinkelmann opened this issue Apr 29, 2024 · 0 comments
Labels

Comments

@clarkwinkelmann
Copy link
Member

Bug Report

Current Behavior
If you leave an empty line in the list of filtered words, every new post will trigger the filter.

This include setting the words list back to an empty string after previously using it. Then there's no way to use just the merge post feature as every post will trigger the filter.

Steps to Reproduce
Leave an empty line in the list of words.

Or save a word, save, then remove all words and save.

It won't happen if the newline is at the beginning or end of the list if it contains any word.

Expected Behavior
Newlines should be ignored or trigger an error on admin save.

Screenshots
If applicable, add screenshots to help explain your problem.

Environment

  • Flarum version: 1.8.5
  • Extension version: 1.1.3, dev-master
  • Website URL: http://example.com
  • Webserver: apache
  • Hosting environment: local
  • PHP version: 8.1.28
Output of "php flarum info", run this in terminal in your Flarum directory.

Possible solution(s)
Ignoring empty lines seem the easiest fix.

If we decide that the filter is required, then the behavior for an empty list of words should be changed when you just enabled the extension and never stored a list of words yet, to match with the behavior of setting a list of words and then removing it.

Additional Context
Here we could add a check for empty string

for ($x = 0, $xMax = count($badwords); $x < $xMax; $x++) {
$censorChecks[$x] = '/'.str_ireplace(array_keys($leet_replace), array_values($leet_replace), $badwords[$x]).'/i';
}

By the way, this could be rewritten as a foreach

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant