From 14c5b6570496f964dc13eb1d43f06d40a7d90f78 Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Thu, 24 Sep 2026 05:55:07 +0200 Subject: [PATCH] refac: tighten details and image patterns in background task message cleanup (#30394) The patterns that remove details blocks and inline images from task messages now stop at the next details tag, bracket or parenthesis. --- backend/open_webui/utils/middleware.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/open_webui/utils/middleware.py b/backend/open_webui/utils/middleware.py index d8ed066c96..164ec4d3a1 100644 --- a/backend/open_webui/utils/middleware.py +++ b/backend/open_webui/utils/middleware.py @@ -3865,7 +3865,7 @@ async def background_tasks_handler(ctx): if isinstance(content, str): content = re.sub( - r']*>.*?<\/details>|!\[.*?\]\(.*?\)', + r']*>(?:(?!|!\[[^\[\]]*\]\([^()]*\)', '', content, flags=re.S | re.I,