fix(memory): sanitize FTS query tokens to handle punctuation

This commit is contained in:
2026-04-27 10:23:42 -07:00
parent 091a851064
commit d9eba53926

3
app.py
View File

@@ -387,7 +387,8 @@ def search_memories(query: str, limit: int = 5) -> list[dict]:
if not query.strip():
return []
db = get_db()
words = [w.strip() for w in query.split() if w.strip()]
# Use alphanumeric token extraction so punctuation (e.g. '?') cannot break FTS MATCH syntax.
words = re.findall(r"[A-Za-z0-9_]+", query)
if not words:
db.close()
return []