Skip to content

[Bug] Multiple Regex Post Filters overwrite each other instead of merging #1865

@CrayonPosse

Description

@CrayonPosse

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.

  1. Create a Post Filter (Filter A) with Title: excludes regex set to pattern a. (any post with the lowercase letter 'a' in the title should be filtered out)
  2. Create a second Post Filter (Filter B) with Title: excludes regex set to pattern b. (any posts with the lowercase letter 'b' in the title should be filtered out)
  3. Apply both filters.
  4. 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.

  1. 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:
    if (p.postTitleExcludesStrings != null && !p.postTitleExcludesStrings.equals("")) {
    stringBuilder = new StringBuilder(postFilter.postTitleExcludesStrings == null ? "" : postFilter.postTitleExcludesStrings);
    stringBuilder.append(",").append(p.postTitleExcludesStrings);
    postFilter.postTitleExcludesStrings = stringBuilder.toString();
    }
  2. The Bug (Regex Filters): For regex exclusions, the code uses a direct assignment operator =, which overwrites the previous value:
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: possible bugIssues that seem to be a bug, but haven't been confirmed yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions