Просмотр исходного кода

Fix: Add validation for dialog name (#8722)

### What problem does this PR solve?

- Validate dialog name in `dialog_app.py` to ensure it is a non-empty
string and does not exceed 255 bytes in UTF-8 encoding.

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
tags/v0.20.0
Liu An 3 месяцев назад
Родитель
Сommit
addda5ccbe
Аккаунт пользователя с таким Email не найден
1 измененных файлов: 6 добавлений и 0 удалений
  1. 6
    0
      api/apps/dialog_app.py

+ 6
- 0
api/apps/dialog_app.py Просмотреть файл

@@ -34,6 +34,12 @@ def set_dialog():
req = request.json
dialog_id = req.get("dialog_id")
name = req.get("name", "New Dialog")
if not isinstance(name, str):
return get_data_error_result(message="Dialog name must be string.")
if name.strip() == "":
return get_data_error_result(message="Dialog name can't be empty.")
if len(name.encode("utf-8")) > 255:
return get_data_error_result(message=f"Dialog name length is {len(name)} which is larger than 255")
description = req.get("description", "A helpful dialog")
icon = req.get("icon", "")
top_n = req.get("top_n", 6)

Загрузка…
Отмена
Сохранить