fix: handle empty message case in common.py and update username regex validation in user.py
Some checks are pending
sync2gitee / repo-sync (push) Waiting to run
Typos Check / Spell Check with Typos (push) Waiting to run

This commit is contained in:
wxg0103 2025-10-20 18:42:55 +08:00
parent 39bd4de6ee
commit 39aaee8e02
2 changed files with 5 additions and 2 deletions

View File

@ -73,6 +73,8 @@ def encryption(message: str):
:param message:
:return:
"""
if not message: # 处理空字符串情况
return "***************"
max_pre_len = 8
max_post_len = 4
message_len = len(message)
@ -335,5 +337,6 @@ def parse_image(content: str):
def generate_uuid(tag: str):
return str(uuid.uuid5(uuid.NAMESPACE_DNS, tag))
def filter_workspace(query_list):
return [q for q in query_list if q.name!="workspace_id"]
return [q for q in query_list if q.name != "workspace_id"]

View File

@ -143,7 +143,7 @@ class UserManageSerializer(serializers.Serializer):
min_length=4,
validators=[
validators.RegexValidator(
regex=re.compile("^.{4,20}$"),
regex=re.compile("^[^\u4e00-\u9fa5]{4,20}$"),
message=_('Username must be 4-20 characters long')
)
]