-
-
Notifications
You must be signed in to change notification settings - Fork 466
Description
Checklist
- I have used the search function for open and closed issues to see if someone else has already submitted the same bug report.
- I will describe the problem with as much detail as possible.
- If the bug only occurs with a certain link, post, image..., I will include the URL.
App version
8.0.8
Where did you get the app from
Other
Android version
16
Device model
SM-S938U1
First occurred
1 day ago
Steps to reproduce
Decided to move this from Discussion #1864 as this is technically a bug.
I noticed that when creating multiple post filters using "Title: excludes regex", posts that should have been filtered out were still appearing.
After reviewing the source code, it appears that while standard keyword filters are correctly merged (concatenated) before application, Regex filters overwrite one another. This means if a user has multiple active filters containing regex, only the last one processed is actually applied.
- Create a Post Filter (Filter A) with
Title: excludes regexset to patterna. (any post with the lowercase letter 'a' in the title should be filtered out) - Create a second Post Filter (Filter B) with
Title: excludes regexset to patternb. (any posts with the lowercase letter 'b' in the title should be filtered out) - Apply both filters.
- Result: Only one of the regex patterns is active (likely the last one loaded). The other is ignored.
Example post, link, markdown...
No response
Expected behaviour
Proposed Solution
The logic for regex filters needs to handle multiple inputs, similar to how strings are handled.
Option A (Quick Fix): Concatenate the regex strings using a pipe | delimiter to create a single valid OR regex (e.g., (RegexA)|(RegexB)).
Option B (Robust Fix): Change the internal handling to a List for regex patterns, appending new patterns to the list during the merge process, and iterating through them during the filtering check.
Option C (More Robust Fix): Consider removing the post filter merging behavior entirely and always process post filters one by one. Not sure of the performance implications of this. The maintainers would probably know better as merging filters was probably an intentional choice for performance reasons. But it would be interesting to see performance comparison that show how many post filters the user would need to create before performance becomes an issue.
Current behaviour
I tracked this down to PostFilter.java.
- The Correct Behavior (String/Keyword Filters): For standard string exclusions, the code uses a StringBuilder to append values, ensuring all keywords from all filters are preserved:
Lines 340 to 344 in ccc3e38
if (p.postTitleExcludesStrings != null && !p.postTitleExcludesStrings.equals("")) { stringBuilder = new StringBuilder(postFilter.postTitleExcludesStrings == null ? "" : postFilter.postTitleExcludesStrings); stringBuilder.append(",").append(p.postTitleExcludesStrings); postFilter.postTitleExcludesStrings = stringBuilder.toString(); } - The Bug (Regex Filters): For regex exclusions, the code uses a direct assignment operator =, which overwrites the previous value:
Lines 332 to 334 in ccc3e38
if (p.postTitleExcludesRegex != null && !p.postTitleExcludesRegex.equals("")) { postFilter.postTitleExcludesRegex = p.postTitleExcludesRegex; }
Current Workaround
Users currently have to manually combine all regex patterns into a single Post Filter entry using pipes (e.g., (pattern1)|(pattern2)), but this is not intuitive and prone to user error.
Logs
No response