Skip to main content

safe_relative_path

Function safe_relative_path 

Source
pub fn safe_relative_path(name: &str) -> Option<PathBuf>
Expand description

Maps an untrusted PBO entry name or prefix to a relative path that cannot leave the folder it is joined to.

The name is split on \ and /. Returns None if any component is empty (a leading, trailing or doubled separator, so an absolute name is never accepted), is . or .., consists only of dots and spaces, is a Windows device name, or contains : (drive letters), a NUL or any control character (C0, DEL and C1, char::is_control), or if the name is empty.