Skip to content

Commit 745473c

Browse files
authored
Validate video image URLs before download (#9819)
Signed-off-by: massy-o <telitos000@gmail.com>
1 parent 594c9fd commit 745473c

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

core/http/endpoints/localai/video.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,19 @@ import (
2222
"github.com/mudler/LocalAI/core/backend"
2323

2424
model "github.com/mudler/LocalAI/pkg/model"
25+
"github.com/mudler/LocalAI/pkg/utils"
2526
"github.com/mudler/xlog"
2627
)
2728

29+
var videoDownloadClient = http.Client{Timeout: 30 * time.Second}
30+
2831
func downloadFile(url string) (string, error) {
32+
if err := utils.ValidateExternalURL(url); err != nil {
33+
return "", fmt.Errorf("URL validation failed: %w", err)
34+
}
35+
2936
// Get the data
30-
resp, err := http.Get(url)
37+
resp, err := videoDownloadClient.Get(url)
3138
if err != nil {
3239
return "", err
3340
}

0 commit comments

Comments
 (0)