From 559abe9971cd149f75e28711a6b228da17344d61 Mon Sep 17 00:00:00 2001 From: -LAN- Date: Wed, 25 Dec 2024 17:51:08 +0800 Subject: [PATCH] fix(audio_service): validate message_id format using UUID Signed-off-by: -LAN- --- api/services/audio_service.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/api/services/audio_service.py b/api/services/audio_service.py index 973110f5156523..ef52301c0aed5d 100644 --- a/api/services/audio_service.py +++ b/api/services/audio_service.py @@ -1,5 +1,6 @@ import io import logging +import uuid from typing import Optional from werkzeug.datastructures import FileStorage @@ -122,6 +123,10 @@ def invoke_tts(text_content: str, app_model, voice: Optional[str] = None): raise e if message_id: + try: + uuid.UUID(message_id) + except ValueError: + return None message = db.session.query(Message).filter(Message.id == message_id).first() if message is None: return None