From 435c34604bc165ba40fc19f61a0da47e02a69ed7 Mon Sep 17 00:00:00 2001 From: Thomas Date: Sun, 13 Nov 2022 10:49:04 +0100 Subject: [PATCH] Fix issue #448 - Issue with regex for whole word --- .../java/app/fedilab/android/helper/TimelineHelper.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/app/fedilab/android/helper/TimelineHelper.java b/app/src/main/java/app/fedilab/android/helper/TimelineHelper.java index b94f6e7b..ed1f39b9 100644 --- a/app/src/main/java/app/fedilab/android/helper/TimelineHelper.java +++ b/app/src/main/java/app/fedilab/android/helper/TimelineHelper.java @@ -92,19 +92,19 @@ public class TimelineHelper { //If there are filters: if (BaseMainActivity.mainFilters != null && BaseMainActivity.mainFilters.size() > 0 && statuses != null && statuses.size() > 0) { for (Filter filter : BaseMainActivity.mainFilters) { - if (filter.irreversible) { //Dealt by the server - continue; - } + for (String filterContext : filter.context) { if (filterTimeLineType.getValue().equalsIgnoreCase(filterContext)) { if (filter.whole_word) { - Pattern p = Pattern.compile("(^" + Pattern.quote(filter.phrase) + "\\b|\\b" + Pattern.quote(filter.phrase) + "$)", Pattern.CASE_INSENSITIVE); + + Pattern p = Pattern.compile("\\b(" + Pattern.quote(filter.phrase) + ")\\b", Pattern.CASE_INSENSITIVE); for (Status status : statuses) { String content; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) content = Html.fromHtml(status.reblog != null ? status.reblog.content : status.content, Html.FROM_HTML_MODE_LEGACY).toString(); else content = Html.fromHtml(status.reblog != null ? status.reblog.content : status.content).toString(); + Matcher m = p.matcher(content); if (m.find()) { statusesToRemove.add(status);