Skip to main content

is_safe_path_component

Function is_safe_path_component 

pub fn is_safe_path_component(alias: &str) -> bool
Expand description

Whether alias is safe to use as one path component inside a bundle.

A skill-bundle alias is a config map key, and the bundle materializes its content at skills/<alias>/. The skill-bundle validator constrains where a bundle’s directory may sit, not what its key may contain, so the key is checked against the format’s own grammar before it is ever joined to a path.

That grammar governs the two kinds of name the bundle format controls: a skill-bundle alias, and each component of a retained aieos_path. Both are read by whoever opens the bundle rather than by the host that wrote it, so the rule is the intersection of what the supported targets accept rather than what this one happens to. Refused: an empty name, leading or trailing whitespace, . and .., a directory separator in either platform’s reading, the characters <>:"|?*, control characters, a trailing dot, and the Windows device names (con, nul, lpt1 and their kin, matched on the stem so an extension is no escape).

The last two are invisible from a Unix host and no less real. A name ending in a space or a dot is silently stripped to a different name on Windows, and a device name opens a device there, so a bundle carrying either resolves somewhere its own manifest does not describe.

This governs the names the format itself controls. It is deliberately not a filter over arbitrary workspace or skill content, which travels under whatever names it already has.