fix: hide check in `canAccess` (#2556)

修复 meta.Password 和 meta.Hide 都为空的情况下,会导致无权限访问
pull/2443/head
浅秋枫影 2022-12-02 17:44:29 +08:00 committed by GitHub
parent 09f480318c
commit ae791c8634
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -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):]) {