From e278f94273db7c3d7bc7781d27dbf06e2f310bdf Mon Sep 17 00:00:00 2001 From: Jarian Cottingham Date: Thu, 2 Jul 2026 19:05:55 +0000 Subject: [PATCH] fix: skip fuzzy matching for short words (<=4 chars) to prevent false positives like 'lofi' matching 'loli' --- web/server/routes/search.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/web/server/routes/search.py b/web/server/routes/search.py index 9f2daca..8c32aac 100644 --- a/web/server/routes/search.py +++ b/web/server/routes/search.py @@ -67,12 +67,12 @@ def _is_banned(query: str) -> bool: # Fuzzy match check for words in the query query_words = query_lower.split() for word in query_words: - # Skip very short words (3 chars or less) - if len(word) <= 3: + # Skip short words (4 chars or less) to avoid false positives (e.g. "lofi" matching "loli") + if len(word) <= 4: continue for term in _banned_terms: - # Skip fuzzy matching for very short banned terms (too many false positives) - if len(term) <= 3: + # Skip fuzzy matching for short banned terms (too many false positives) + if len(term) <= 4: continue # Only fuzzy match for terms with similar length if abs(len(word) - len(term)) > 2: