mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-03-05 20:49:04 -08:00
fix(font): only install from the specified folder
This commit is contained in:
parent
ba25c47b73
commit
cb7a5d0dd8
|
@ -2,6 +2,7 @@ package cli
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/jandedobbeleer/oh-my-posh/src/font"
|
"github.com/jandedobbeleer/oh-my-posh/src/font"
|
||||||
"github.com/jandedobbeleer/oh-my-posh/src/runtime"
|
"github.com/jandedobbeleer/oh-my-posh/src/runtime"
|
||||||
|
@ -47,6 +48,10 @@ This command is used to install fonts and configure the font in your terminal.
|
||||||
|
|
||||||
terminal.Init(env.Shell())
|
terminal.Init(env.Shell())
|
||||||
|
|
||||||
|
if !strings.HasPrefix(zipFolder, "/") {
|
||||||
|
zipFolder += "/"
|
||||||
|
}
|
||||||
|
|
||||||
font.Run(fontName, env.Cache(), env.Root(), zipFolder)
|
font.Run(fontName, env.Cache(), env.Root(), zipFolder)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
|
@ -36,20 +36,19 @@ func InstallZIP(data []byte, m *main) ([]string, error) {
|
||||||
|
|
||||||
fonts := make(map[string]*Font)
|
fonts := make(map[string]*Font)
|
||||||
|
|
||||||
root := len(m.zipFolder) == 0
|
|
||||||
|
|
||||||
for _, file := range zipReader.File {
|
for _, file := range zipReader.File {
|
||||||
// prevent zipslip attacks
|
// prevent zipslip attacks
|
||||||
// https://security.snyk.io/research/zip-slip-vulnerability
|
// https://security.snyk.io/research/zip-slip-vulnerability
|
||||||
// and only process files which are in the specified folder
|
// skip folders
|
||||||
if strings.Contains(file.Name, "..") || !strings.HasPrefix(file.Name, m.zipFolder) {
|
if strings.Contains(file.Name, "..") || strings.HasSuffix(file.Name, "/") {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
fontFileName := path.Base(file.Name)
|
fontFileName := path.Base(file.Name)
|
||||||
|
fontRelativeFileName := strings.TrimPrefix(file.Name, m.zipFolder)
|
||||||
|
|
||||||
// do not install fonts that are not in the root folder when specified as such
|
// do not install fonts that are not in the specified installation folder
|
||||||
if root && fontFileName != file.Name {
|
if fontFileName != fontRelativeFileName {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue