From 5ce0f216cf3c60094eb3235833e2018dfc23cc2d Mon Sep 17 00:00:00 2001 From: Dave Date: Sun, 30 Jul 2023 03:47:22 -0400 Subject: [PATCH] Fix: Model Gallery Downloads (#835) --- pkg/utils/path.go | 2 +- pkg/utils/uri.go | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/utils/path.go b/pkg/utils/path.go index 58085125111e..05481d2cc2a5 100644 --- a/pkg/utils/path.go +++ b/pkg/utils/path.go @@ -18,5 +18,5 @@ func inTrustedRoot(path string, trustedRoot string) error { // VerifyPath verifies that path is based in basePath. func VerifyPath(path, basePath string) error { c := filepath.Clean(filepath.Join(basePath, path)) - return inTrustedRoot(c, basePath) + return inTrustedRoot(c, filepath.Clean(basePath)) } diff --git a/pkg/utils/uri.go b/pkg/utils/uri.go index 95527457ac74..b79b5fc355ad 100644 --- a/pkg/utils/uri.go +++ b/pkg/utils/uri.go @@ -2,8 +2,9 @@ package utils import ( "fmt" - "io/ioutil" + "io" "net/http" + "os" "strings" ) @@ -32,7 +33,7 @@ func GetURI(url string, f func(url string, i []byte) error) error { if strings.HasPrefix(url, "file://") { rawURL := strings.TrimPrefix(url, "file://") // Read the response body - body, err := ioutil.ReadFile(rawURL) + body, err := os.ReadFile(rawURL) if err != nil { return err } @@ -49,7 +50,7 @@ func GetURI(url string, f func(url string, i []byte) error) error { defer response.Body.Close() // Read the response body - body, err := ioutil.ReadAll(response.Body) + body, err := io.ReadAll(response.Body) if err != nil { return err }