MCPcopy Create free account
hub / github.com/github/gh-aw / isValidFileExtension

Function isValidFileExtension

pkg/workflow/cache.go:81–94  ·  view source on GitHub ↗

isValidFileExtension reports whether s is a valid file extension of the form ^\.[A-Za-z0-9]+$ (e.g. ".json", ".md"). This strict pattern prevents YAML injection when extensions are embedded in generated workflow YAML as single-quoted scalars.

(s string)

Source from the content-addressed store, hash-verified

79// (e.g. ".json", ".md"). This strict pattern prevents YAML injection when extensions are
80// embedded in generated workflow YAML as single-quoted scalars.
81func isValidFileExtension(s string) bool {
82 if len(s) < 2 || s[0] != '.' {
83 return false
84 }
85 for _, c := range s[1:] {
86 isLower := c >= 'a' && c <= 'z'
87 isUpper := c >= 'A' && c <= 'Z'
88 isDigit := c >= '0' && c <= '9'
89 if !isLower && !isUpper && !isDigit {
90 return false
91 }
92 }
93 return true
94}
95
96// CacheMemoryConfig holds configuration for cache-memory functionality
97type CacheMemoryConfig struct {

Calls

no outgoing calls