From ae791c8634f18440d8431bb502faff4a77292bef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B5=85=E7=A7=8B=E6=9E=AB=E5=BD=B1?= <18218380+naicfeng@users.noreply.github.com> Date: Fri, 2 Dec 2022 17:44:29 +0800 Subject: [PATCH] fix: hide check in `canAccess` (#2556) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复 meta.Password 和 meta.Hide 都为空的情况下,会导致无权限访问 --- server/common/check.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/common/check.go b/server/common/check.go index d0fa6b94..63cd72a4 100644 --- a/server/common/check.go +++ b/server/common/check.go @@ -17,7 +17,7 @@ func CanWrite(meta *model.Meta, path string) bool { func CanAccess(user *model.User, meta *model.Meta, reqPath string, password string) bool { // if the reqPath is in hide (only can check the nearest meta) and user can't see hides, can't access - if meta != nil && !user.CanSeeHides() { + if meta != nil && !user.CanSeeHides() && meta.Hide != "" { for _, hide := range strings.Split(meta.Hide, "\n") { re := regexp.MustCompile(hide) if re.MatchString(reqPath[len(meta.Path):]) {