mirror of
https://github.com/AlistGo/alist.git
synced 2025-04-21 20:18:47 +08:00
fix: avoid regular expression match current directory (#3078)
* fix: avoid regular expression match current directory * fix: optimize and regexp exclude slash Co-authored-by: wuxuan <refused@wuxuan.eu.org>
This commit is contained in:
parent
0a337756ba
commit
530e74c70b
@ -17,10 +17,10 @@ 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() && meta.Hide != "" {
|
||||
if meta != nil && !user.CanSeeHides() && meta.Hide != "" && !utils.PathEqual(meta.Path, reqPath) {
|
||||
for _, hide := range strings.Split(meta.Hide, "\n") {
|
||||
re := regexp.MustCompile(hide)
|
||||
if re.MatchString(reqPath[len(meta.Path):]) {
|
||||
if re.MatchString(reqPath[len(meta.Path)+1:]) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user