mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Cleanup safe path setting location
This commit is contained in:
parent
ed69bff645
commit
e5e98f7fc8
@ -14,6 +14,7 @@ type SettingsT struct {
|
||||
Outpath string
|
||||
Metadata string
|
||||
RoutePrefix string
|
||||
SafePath string
|
||||
HwAccel HwAccelT
|
||||
}
|
||||
|
||||
@ -28,5 +29,6 @@ var Settings = SettingsT{
|
||||
Outpath: GetEnvOr("GOCODER_CACHE_ROOT", "/cache"),
|
||||
Metadata: GetEnvOr("GOCODER_METADATA_ROOT", "/metadata"),
|
||||
RoutePrefix: GetEnvOr("GOCODER_PREFIX", ""),
|
||||
SafePath: GetEnvOr("GOCODER_SAFE_PATH", "/video"),
|
||||
HwAccel: DetectHardwareAccel(),
|
||||
}
|
||||
|
@ -14,8 +14,6 @@ import (
|
||||
"github.com/zoriya/kyoo/transcoder/src"
|
||||
)
|
||||
|
||||
var safe_path = src.GetEnvOr("GOCODER_SAFE_PATH", "/video")
|
||||
|
||||
// Encode the version in the hash path to update cached values.
|
||||
// Older versions won't be deleted (needed to allow multiples versions of the transcoder to run at the same time)
|
||||
// If the version changes a lot, we might want to automatically delete older versions.
|
||||
@ -34,7 +32,7 @@ func GetPath(c echo.Context) (string, string, error) {
|
||||
if !filepath.IsAbs(path) {
|
||||
return "", "", echo.NewHTTPError(http.StatusBadRequest, "Absolute path required.")
|
||||
}
|
||||
if !strings.HasPrefix(path, safe_path) {
|
||||
if !strings.HasPrefix(path, src.Settings.SafePath) {
|
||||
return "", "", echo.NewHTTPError(http.StatusBadRequest, "Selected path is not marked as safe.")
|
||||
}
|
||||
hash, err := getHash(path)
|
||||
|
Loading…
x
Reference in New Issue
Block a user