Skip to main content

validate_database_name

Function validate_database_name 

Source
pub fn validate_database_name(name: &str) -> Result<()>
Expand description

Validate a database name supplied by the model.

The name is not just a label: create_database turns it into a filesystem path (./netget_db_<name>.db) that delete_database later remove_files. A name containing /, .., a NUL, or a leading / therefore reads and destroys files outside the working directory. Generated text must never reach a path builder unchecked, so the name is checked against a strict allowlist and rejected rather than sanitised — a silently rewritten name would make the model’s own bookkeeping (it refers to databases by name) disagree with what exists on disk.