From 052966e07ce2e5de2b7e3a0b9e8f054c1542927c Mon Sep 17 00:00:00 2001 From: Xiaolan Bot Date: Sun, 22 Feb 2026 11:30:22 +0800 Subject: [PATCH] fix: validate name/notes constraints in edit flow --- SubMind.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/SubMind.py b/SubMind.py index 57929c9..0762669 100644 --- a/SubMind.py +++ b/SubMind.py @@ -1163,6 +1163,16 @@ async def edit_new_value_received(update: Update, context: CallbackContext): if message_to_reply: await message_to_reply.reply_text("费用必须是有效的非负数字。") validation_failed = True + elif field == 'name': + new_value = str(new_value).strip() + if not new_value: + if message_to_reply: + await message_to_reply.reply_text("名称不能为空。") + validation_failed = True + elif len(new_value) > MAX_NAME_LEN: + if message_to_reply: + await message_to_reply.reply_text(f"名称过长,请控制在 {MAX_NAME_LEN} 个字符以内。") + validation_failed = True elif field == 'currency': new_value = str(new_value).upper() if not (len(new_value) == 3 and new_value.isalpha()): @@ -1182,6 +1192,14 @@ async def edit_new_value_received(update: Update, context: CallbackContext): if message_to_reply: await message_to_reply.reply_text("续费方式只能为 auto 或 manual。") validation_failed = True + elif field == 'notes': + note_val = str(new_value).strip() + if note_val and len(note_val) > MAX_NOTES_LEN: + if message_to_reply: + await message_to_reply.reply_text(f"备注过长,请控制在 {MAX_NOTES_LEN} 个字符以内。") + validation_failed = True + else: + new_value = note_val if note_val else None elif field == 'category': new_value = str(new_value).strip() if not new_value: