Fix: sub path join is url encode, can not check prefix

pull/154/head
zijiren233 10 months ago
parent efce1e4a67
commit 16686c470f

@ -7,7 +7,7 @@ import (
"fmt"
"io"
"net/http"
"net/url"
"path"
"strings"
"time"
@ -184,10 +184,7 @@ func NewAlistMovieCacheInitFunc(movie *model.Movie, subPath string) func(ctx con
return nil, err
}
if movie.IsFolder {
newPath, err := url.JoinPath(truePath, subPath)
if err != nil {
return nil, err
}
newPath := path.Join(truePath, subPath)
// check new path is in parent path
if !strings.HasPrefix(newPath, truePath) {
return nil, errors.New("sub path is not in parent path")

@ -12,6 +12,7 @@ import (
"math/rand"
"net/http"
"net/url"
"path"
"path/filepath"
"strconv"
"strings"
@ -309,10 +310,7 @@ func listVendorDynamicMovie(ctx context.Context, reqUser *op.User, room *op.Room
if err != nil {
return nil, fmt.Errorf("load alist server id error: %w", err)
}
newPath, err := url.JoinPath(truePath, subPath)
if err != nil {
return nil, fmt.Errorf("join path error: %w", err)
}
newPath := path.Join(truePath, subPath)
// check new path is in parent path
if !strings.HasPrefix(newPath, truePath) {
return nil, fmt.Errorf("sub path is not in parent path")

Loading…
Cancel
Save