fix: some missing regexp lib modified
This commit is contained in:
parent
478470f609
commit
57bac9e0d2
@ -2,7 +2,6 @@ package common
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"path"
|
"path"
|
||||||
"regexp"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/alist-org/alist/v3/internal/conf"
|
"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/model"
|
||||||
"github.com/alist-org/alist/v3/internal/op"
|
"github.com/alist-org/alist/v3/internal/op"
|
||||||
"github.com/alist-org/alist/v3/pkg/utils"
|
"github.com/alist-org/alist/v3/pkg/utils"
|
||||||
|
"github.com/dlclark/regexp2"
|
||||||
)
|
)
|
||||||
|
|
||||||
func IsStorageSignEnabled(rawPath string) bool {
|
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 != "" &&
|
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
|
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") {
|
for _, hide := range strings.Split(meta.Hide, "\n") {
|
||||||
re := regexp.MustCompile(hide)
|
re := regexp2.MustCompile(hide, regexp2.None)
|
||||||
if re.MatchString(path.Base(reqPath)) {
|
if isMatch, _ := re.MatchString(path.Base(reqPath)); isMatch {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,13 +2,13 @@ package handles
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"regexp"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/alist-org/alist/v3/internal/model"
|
"github.com/alist-org/alist/v3/internal/model"
|
||||||
"github.com/alist-org/alist/v3/internal/op"
|
"github.com/alist-org/alist/v3/internal/op"
|
||||||
"github.com/alist-org/alist/v3/server/common"
|
"github.com/alist-org/alist/v3/server/common"
|
||||||
|
"github.com/dlclark/regexp2"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
@ -71,7 +71,7 @@ func UpdateMeta(c *gin.Context) {
|
|||||||
func validHide(hide string) (string, error) {
|
func validHide(hide string) (string, error) {
|
||||||
rs := strings.Split(hide, "\n")
|
rs := strings.Split(hide, "\n")
|
||||||
for _, r := range rs {
|
for _, r := range rs {
|
||||||
_, err := regexp.Compile(r)
|
_, err := regexp2.Compile(r, regexp2.None)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return r, err
|
return r, err
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user