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.
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
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
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
https://github.com/FriendsOfFlarum/filter/blob/347c235c306c5714abb99124dd8ec535191a42c9/src/Listener/AddCensorChecks.php#L52-L54
By the way, this could be rewritten as a
foreach