Function rustful::file::check_path [] [src]

pub fn check_path<P: ?Sized + AsRef<Path>>(path: &P) -> Result<(), Component>

Check if a path tries to escape its parent directory.

Forbidden path components:

Allowed path components:

The first forbidden component is returned if the path is invalid.

use std::path::Component;
use rustful::file::check_path;

let bad_path = "..";

assert_eq!(check_path(bad_path), Err(Component::ParentDir));