From b88882d28bce182941aaa4c3b4f0d0246d352eb4 Mon Sep 17 00:00:00 2001 From: "weihong.xu" Date: Thu, 31 Oct 2024 17:17:22 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E5=90=88=E6=B3=95?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=90=8D=E8=B4=A6=E5=8F=B7=E5=90=8D=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/utils.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/utils/utils.go b/utils/utils.go index ca09ffa..21a5de3 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -336,9 +336,10 @@ func GetUserNameByUid(uid int) (string, error) { return u.Username, nil } -// 判断字符串中是否包含大写字母 +// 判断字符串是否为合法用户名或账号名 func CheckAccountOrUserStrings(s string) bool { - pattern := "^[a-z0-9_]+$" + // 允许字母、数字、下划线、连字符 + pattern := "^[a-zA-Z0-9_-]+$" // 编译正则表达式 reg := regexp.MustCompile(pattern) // 使用正则表达式判断字符串是否符合模式 From 2352e2637f6a4cf46b55dddd4a7b5f9baa184810 Mon Sep 17 00:00:00 2001 From: "weihong.xu" Date: Fri, 1 Nov 2024 10:46:15 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E5=90=88=E6=B3=95?= =?UTF-8?q?=E8=B4=A6=E5=8F=B7=E5=90=8D=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/utils.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/utils.go b/utils/utils.go index 21a5de3..02a7dce 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -338,8 +338,8 @@ func GetUserNameByUid(uid int) (string, error) { // 判断字符串是否为合法用户名或账号名 func CheckAccountOrUserStrings(s string) bool { - // 允许字母、数字、下划线、连字符 - pattern := "^[a-zA-Z0-9_-]+$" + // 允许小写字母、数字、下划线、连字符 + pattern := "^[a-z0-9_-]+$" // 编译正则表达式 reg := regexp.MustCompile(pattern) // 使用正则表达式判断字符串是否符合模式 From aa3d2c74f45763713be8f281722a4dec2cc09ac4 Mon Sep 17 00:00:00 2001 From: "weihong.xu" Date: Fri, 1 Nov 2024 15:44:00 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E5=90=88=E6=B3=95?= =?UTF-8?q?=E8=B4=A6=E5=8F=B7=E5=90=8D=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/utils.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/utils.go b/utils/utils.go index 02a7dce..9574c19 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -338,8 +338,8 @@ func GetUserNameByUid(uid int) (string, error) { // 判断字符串是否为合法用户名或账号名 func CheckAccountOrUserStrings(s string) bool { - // 允许小写字母、数字、下划线、连字符 - pattern := "^[a-z0-9_-]+$" + // 允许小写字母、数字、下划线、连字符, 不以连字符开头 + pattern := "^(?!-)[a-z0-9_-]+$" // 编译正则表达式 reg := regexp.MustCompile(pattern) // 使用正则表达式判断字符串是否符合模式