Import: Allow directory names with dots #2807

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer 2022-10-27 15:47:32 +02:00
parent 52af69ae21
commit 6a33ae2e93
4 changed files with 7 additions and 7 deletions

View File

@ -67,7 +67,7 @@ func SearchFolders(router *gin.RouterGroup, urlPath, rootName, rootPath string)
listFiles := f.Files
uncached := listFiles || f.Uncached
resp := FoldersResponse{Root: rootName, Recursive: recursive, Cached: !uncached}
path := clean.Path(c.Param("path"))
path := clean.UserPath(c.Param("path"))
cacheKey := fmt.Sprintf("folder:%s:%t:%t", filepath.Join(rootName, path), recursive, listFiles)

View File

@ -58,10 +58,10 @@ func StartImport(router *gin.RouterGroup) {
importPath := conf.ImportPath()
// Import from sub-folder?
if srcFolder = clean.Path(c.Param("path")); srcFolder != "" && srcFolder != "/" {
srcFolder = strings.Replace(srcFolder, ".", "", -1)
if srcFolder = c.Param("path"); srcFolder != "" && srcFolder != "/" {
srcFolder = clean.UserPath(srcFolder)
} else if f.Path != "" {
srcFolder = strings.Replace(f.Path, ".", "", -1)
srcFolder = clean.UserPath(f.Path)
}
// To avoid conflicts, uploads are imported from "import_path/upload/session_ref/timestamp".

View File

@ -33,8 +33,8 @@ func NewUserFromCli(ctx *cli.Context) User {
CanLogin: !ctx.Bool("no-login"),
WebDAV: ctx.Bool("webdav"),
UserAttr: clean.Attr(ctx.String("attr")),
BasePath: clean.Path(ctx.String("base-path")),
UploadPath: clean.Path(ctx.String("upload-path")),
BasePath: clean.UserPath(ctx.String("base-path")),
UploadPath: clean.UserPath(ctx.String("upload-path")),
Password: clean.Password(ctx.String("password")),
}
}

View File

@ -32,7 +32,7 @@ func Path(s string) string {
return s
}
// UserPath sanitizes and normalizes a user provided path so it can be used
// UserPath sanitizes and normalizes a user provided path, so it can be used.
func UserPath(dir string) string {
if dir == "" {
return dir