From 57bac9e0d2a674a78f45234460ecd4fcbcbd9f78 Mon Sep 17 00:00:00 2001 From: Andy Hsu Date: Mon, 1 Jan 2024 17:16:07 +0800 Subject: [PATCH] fix: some missing regexp lib modified --- server/common/check.go | 6 +++--- server/handles/meta.go | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/server/common/check.go b/server/common/check.go index 1f4227b000d..78051f4ee1e 100644 --- a/server/common/check.go +++ b/server/common/check.go @@ -2,7 +2,6 @@ package common import ( "path" - "regexp" "strings" "github.com/alist-org/alist/v3/internal/conf" @@ -10,6 +9,7 @@ import ( "github.com/alist-org/alist/v3/internal/model" "github.com/alist-org/alist/v3/internal/op" "github.com/alist-org/alist/v3/pkg/utils" + "github.com/dlclark/regexp2" ) func IsStorageSignEnabled(rawPath string) bool { @@ -36,8 +36,8 @@ func CanAccess(user *model.User, meta *model.Meta, reqPath string, password stri if meta != nil && !user.CanSeeHides() && meta.Hide != "" && IsApply(meta.Path, path.Dir(reqPath), meta.HSub) { // the meta should apply to the parent of current path for _, hide := range strings.Split(meta.Hide, "\n") { - re := regexp.MustCompile(hide) - if re.MatchString(path.Base(reqPath)) { + re := regexp2.MustCompile(hide, regexp2.None) + if isMatch, _ := re.MatchString(path.Base(reqPath)); isMatch { return false } } diff --git a/server/handles/meta.go b/server/handles/meta.go index e7454d9df5a..00aa3137192 100644 --- a/server/handles/meta.go +++ b/server/handles/meta.go @@ -2,13 +2,13 @@ package handles import ( "fmt" - "regexp" "strconv" "strings" "github.com/alist-org/alist/v3/internal/model" "github.com/alist-org/alist/v3/internal/op" "github.com/alist-org/alist/v3/server/common" + "github.com/dlclark/regexp2" "github.com/gin-gonic/gin" log "github.com/sirupsen/logrus" ) @@ -71,7 +71,7 @@ func UpdateMeta(c *gin.Context) { func validHide(hide string) (string, error) { rs := strings.Split(hide, "\n") for _, r := range rs { - _, err := regexp.Compile(r) + _, err := regexp2.Compile(r, regexp2.None) if err != nil { return r, err }