Skip to main content
Filename validation utilities for the decompose pipeline. Provides validate_filename, which checks that a candidate output filename contains only safe characters (alphanumeric, underscores, hyphens, periods, and spaces) and falls within a reasonable length limit. Used to prevent path-traversal or shell-injection issues when writing decomposition output files.

Functions

FUNC validate_filename

validate_filename(candidate_str: str) -> bool
Check whether a string is safe to use as an output filename. Permits alphanumeric characters, underscores, hyphens, periods, and spaces; the first character must be alphanumeric, an underscore, or a period. Also enforces a maximum length of 250 characters. Args:
  • candidate_str: The filename candidate to validate.
Returns:
  • True if the string is a safe, valid filename; False otherwise.