mirror of
https://github.com/mudler/LocalAI.git
synced 2025-05-21 19:15:00 +00:00
feat: add tts with go-piper (#649)
Signed-off-by: mudler <mudler@localai.io>
This commit is contained in:
parent
cc31c58235
commit
a7bb029d23
14 changed files with 237 additions and 29 deletions
22
pkg/utils/path.go
Normal file
22
pkg/utils/path.go
Normal file
|
@ -0,0 +1,22 @@
|
|||
package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
func inTrustedRoot(path string, trustedRoot string) error {
|
||||
for path != "/" {
|
||||
path = filepath.Dir(path)
|
||||
if path == trustedRoot {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
return fmt.Errorf("path is outside of trusted root")
|
||||
}
|
||||
|
||||
// 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)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue