Hwaro::Utils::PathUtils
Instance methods
File.match? that treats a malformed glob as non-matching instead of raising File::BadPatternError, so a single config typo can't crash a build or deploy.
True when path, with all symbolic links resolved, lies inside
root (also fully resolved). Used to stop symlinked source files
from publishing content that lives outside the project — e.g. a
static/leak -> ~/.ssh/id_rsa symlink would otherwise be copied
into the public output. In-repo symlinks resolve back within the
root and are kept. Returns false on a dangling/unreadable path
rather than raising.
Sanitize path to prevent directory traversal and normalize separators
This method performs the following operations:
- URL-decodes the path (repeated until stable to catch double-encoding)
- Removes null bytes
- Splits into segments and rejects ".." components
- Rejoins with "/" separator
Example: sanitize_path("/foo/../bar//baz/") # => "foo/bar/baz" sanitize_path("%2Ffoo%2Fbar") # => "foo/bar" sanitize_path("....//etc/passwd") # => "etc/passwd"