fix(get): prevents templating invalid utf8 values

This commit is contained in:
Lewis Wynne 2026-02-14 01:41:40 +00:00
parent f5fb9ec96b
commit 9914f51140

View file

@ -29,6 +29,7 @@ import (
"os/exec" "os/exec"
"strings" "strings"
"text/template" "text/template"
"unicode/utf8"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
@ -117,7 +118,7 @@ func get(cmd *cobra.Command, args []string) error {
return fmt.Errorf("cannot get '%s': %v", args[0], err) return fmt.Errorf("cannot get '%s': %v", args[0], err)
} }
if !noTemplate { if !noTemplate && utf8.Valid(v) {
var substitutions []string var substitutions []string
if len(args) > 1 { if len(args) > 1 {
substitutions = args[1:] substitutions = args[1:]