package web

import (
	"path/filepath"
	"strings"
)

// validStackName reports whether name is a safe stack identifier: a single path segment, never a path.
// Rejects traversal/escape (`..`, `/`, `\`, NUL) so a stack_name can never be turned into a filesystem
// path that escapes the stacks/userdata tree. (Storage `where=` is validated separately by gateWhere.)
func validStackName(name string) bool {
	if name == "" || name == "." || name == ".." {
		return false
	}
	if strings.ContainsAny(name, "/\\\x00") {
		return false
	}
	return name == filepath.Clean(name)
}
