diff --git a/backend/open_webui/models/automations.py b/backend/open_webui/models/automations.py index 8c7f6089e3..954026cfc8 100644 --- a/backend/open_webui/models/automations.py +++ b/backend/open_webui/models/automations.py @@ -195,7 +195,7 @@ class AutomationTable: stmt = stmt.filter( or_( Automation.name.ilike(f'%{query}%'), - *(data_text.ilike(f'%{variant}%') for variant in json_text_variants(query)), + *(data_text.icontains(variant, autoescape=True) for variant in json_text_variants(query)), ) ) diff --git a/backend/open_webui/models/models.py b/backend/open_webui/models/models.py index 8da346ab70..d48f1e9008 100755 --- a/backend/open_webui/models/models.py +++ b/backend/open_webui/models/models.py @@ -392,7 +392,9 @@ class ModelsTable: else: meta_text = func.lower(cast(Model.meta, String)) variants = json_text_variants(tag.lower()) - stmt = stmt.filter(or_(*(meta_text.like(f'%"{variant}"%') for variant in variants))) + stmt = stmt.filter( + or_(*(meta_text.contains(f'"{variant}"', autoescape=True) for variant in variants)) + ) order_by = filter.get('order_by') direction = filter.get('direction') diff --git a/backend/open_webui/models/prompts.py b/backend/open_webui/models/prompts.py index f0e4a3e9b8..75cc93b5a8 100644 --- a/backend/open_webui/models/prompts.py +++ b/backend/open_webui/models/prompts.py @@ -346,7 +346,10 @@ class PromptsTable: # Fallback for dialects with no JSON array function: LIKE on the text. tags_text = func.lower(cast(Prompt.tags, String)) tag_clause = or_( - *(tags_text.like(f'%"{variant}"%') for variant in json_text_variants(tag_lower)) + *( + tags_text.contains(f'"{variant}"', autoescape=True) + for variant in json_text_variants(tag_lower) + ) ) tag_lower = None