pub fn file_path() -> Sanitizer<FilePath>Expand description
Sanitizer for relative file paths.
Use for upload destinations, template includes, plugin paths, or
any path that must stay within a base directory. Rejects absolute
paths and .. traversal.
§Rules
PathTraversalRule—.., absolute paths, drive lettersControlCharRule— NUL, newline, ANSI escapes
§Example
use shell_sanitize_rules::presets;
let s = presets::file_path();
// Relative path within allowed directory
assert!(s.sanitize("uploads/photo.jpg").is_ok());
// Traversal attack
assert!(s.sanitize("../../etc/passwd").is_err());
// Absolute path escape
assert!(s.sanitize("/etc/shadow").is_err());