You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since #23493 has conflicts with latest commits, this PR is my proposal
for fixing #23371
Details are in the comments
And refactor the `modules/options` module, to make it always use
"filepath" to access local files.
Benefits:
* No need to do `util.CleanPath(strings.ReplaceAll(p, "\\", "/"))),
"/")` any more (not only one before)
* The function behaviors are clearly defined
// WalkLocales reads the content of a specific locale
@@ -79,17 +81,54 @@ func walkAssetDir(root string, callback func(path, name string, d fs.DirEntry, e
79
81
returnnil
80
82
}
81
83
82
-
funcstatDirIfExist(dirstring) ([]string, error) {
83
-
isDir, err:=util.IsDir(dir)
84
+
// mustLocalPathAbs coverts a path to absolute path
85
+
// FIXME: the old behavior (StaticRootPath might not be absolute), not ideal, just keep the same as before
86
+
funcmustLocalPathAbs(sstring) string {
87
+
abs, err:=filepath.Abs(s)
84
88
iferr!=nil {
85
-
returnnil, fmt.Errorf("unable to check if static directory %s is a directory. %w", dir, err)
89
+
// This should never happen in a real system. If it happens, the user must have already been in trouble: the system is not able to resolve its own paths.
90
+
log.Fatal("Unable to get absolute path for %q: %v", s, err)
// use clean to keep the file is a valid path with no . or ..
106
-
f, err:=fs.Open(util.CleanPath(file))
95
+
// actually, fs (http.FileSystem) is designed to be a safe interface, relative paths won't bypass its parent directory, it's also fine to do a clean here
returnnil, fmt.Errorf("LocalStorageConfig.Path should have been prepared by setting/storage.go and should be an absolute path, but not: %q", config.Path)
46
+
}
44
47
log.Info("Creating new Local Storage at %s", config.Path)
0 commit comments