Skip to content

Commit 39aaee8

Browse files
committed
fix: handle empty message case in common.py and update username regex validation in user.py
1 parent 39bd4de commit 39aaee8

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

apps/common/utils/common.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ def encryption(message: str):
7373
:param message:
7474
:return:
7575
"""
76+
if not message: # 处理空字符串情况
77+
return "***************"
7678
max_pre_len = 8
7779
max_post_len = 4
7880
message_len = len(message)
@@ -335,5 +337,6 @@ def parse_image(content: str):
335337
def generate_uuid(tag: str):
336338
return str(uuid.uuid5(uuid.NAMESPACE_DNS, tag))
337339

340+
338341
def filter_workspace(query_list):
339-
return [q for q in query_list if q.name!="workspace_id"]
342+
return [q for q in query_list if q.name != "workspace_id"]

apps/users/serializers/user.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ class UserInstance(serializers.Serializer):
143143
min_length=4,
144144
validators=[
145145
validators.RegexValidator(
146-
regex=re.compile("^.{4,20}$"),
146+
regex=re.compile("^[^\u4e00-\u9fa5]{4,20}$"),
147147
message=_('Username must be 4-20 characters long')
148148
)
149149
]

0 commit comments

Comments
 (0)